cowboy_swagger (cowboy_swagger v2.8.0)
View Sourcecowboy-swagger main interface.
Summary
Functions
Returns the swagger json specification from given trails. This function basically takes the metadata from each t:trails:trail() (which must be compliant with Swagger specification) and builds the required swagger.json.
Returns the swagger json specification from given trails and server_spec`. This function takes the metadata from each `t:trails:trail() and combines it with the data stored in server_spec. If no data is stored in server_spec related to the listener use global_spec instead.
Types
-type metadata() :: trails:metadata(swagger_map()).
-type parameter_definition_name() :: binary().
-opaque parameter_obj()
-type parameters_definition_array() :: #{parameter_definition_name() => #{type => binary(), items => #{type => binary(), properties => property_obj()}}}.
-type parameters_definitions() :: #{parameter_definition_name() => #{type => binary(), properties => property_obj(), _ => _}}.
-type property_desc() :: #{type => binary(), description => binary(), example => binary(), items => property_desc()}.
-type property_obj() :: #{binary() => property_desc()}.
-opaque response_obj()
-type responses_definitions() :: #{binary() => response_obj()}.
-opaque swagger_map()
-type swagger_version() :: swagger_2_0 | openapi_3_0_0.
Functions
-spec add_definition(Definition :: parameters_definitions() | parameters_definition_array()) -> ok.
-spec add_definition(Name :: parameter_definition_name(), Properties :: property_obj()) -> ok.
-spec add_definition_array(Name :: parameter_definition_name(), Properties :: property_obj()) -> ok.
-spec add_definition_array_to_server(Server :: ranch:ref(), Name :: parameter_definition_name(), Properties :: property_obj()) -> ok.
-spec add_definition_to_server(Server :: ranch:ref(), Definition :: parameters_definitions() | parameters_definition_array()) -> ok.
-spec add_definition_to_server(Server :: ranch:ref(), Name :: parameter_definition_name(), Properties :: property_obj()) -> ok.
-spec get_existing_definitions(CurrentSpec :: jsx:json_term(), Type :: atom() | binary()) -> Definition :: parameters_definitions() | parameters_definition_array().
-spec get_existing_server_definitions(Server :: ranch:ref(), CurrentSpec :: jsx:json_term(), Type :: atom() | binary()) -> Definition :: parameters_definitions() | parameters_definition_array().
-spec get_global_spec() -> jsx:json_term().
-spec get_global_spec(jsx:json_term()) -> jsx:json_term().
-spec get_server_spec() -> #{ranch:ref() := jsx:json_term()}.
-spec get_server_spec(ranch:ref()) -> jsx:json_term().
-spec get_server_spec(ranch:ref(), jsx:json_term()) -> jsx:json_term().
-spec schema(DefinitionName :: parameter_definition_name()) -> #{<<_:32>> => <<_:64, _:_*8>>}.
-spec server_schema(Server :: ranch:ref(), DefinitionName :: parameter_definition_name()) -> #{<<_:32>> => <<_:64, _:_*8>>}.
-spec set_global_spec(jsx:json_term()) -> ok.
-spec set_server_spec(ranch:ref(), jsx:json_term()) -> ok.
-spec to_json([trails:trail()]) -> jsx:json_text().
Returns the swagger json specification from given trails. This function basically takes the metadata from each t:trails:trail() (which must be compliant with Swagger specification) and builds the required swagger.json.
-spec to_json(ranch:ref(), [trails:trail()]) -> jsx:json_text().
Returns the swagger json specification from given trails and server_spec`. This function takes the metadata from each `t:trails:trail() and combines it with the data stored in server_spec. If no data is stored in server_spec related to the listener use global_spec instead.