ZoiPhoenixSwagger (zoi_phoenix_swagger v0.1.1)
View SourceIntegration between Zoi schema validation and Phoenix Swagger documentation.
Converts Zoi schemas into Phoenix Swagger parameter definitions.
Summary
Functions
Converts a Zoi schema to Phoenix Swagger parameters.
Converts a Zoi schema to a Phoenix Swagger schema definition.
Functions
@spec parameters(PhoenixSwagger.Path.PathObject.t(), Zoi.schema()) :: PhoenixSwagger.Path.PathObject.t()
Converts a Zoi schema to Phoenix Swagger parameters.
Usage in swagger_path block:
swagger_path :index do
get("/api/categories/{category_id}")
ZoiPhoenixSwagger.parameters(@index_params)
endThe phoenix_swagger macro automatically injects path_object as first argument.
@spec schema_definition(Zoi.schema()) :: map()
Converts a Zoi schema to a Phoenix Swagger schema definition.
Returns a JSON map (with string keys) suitable for use in swagger_definitions/0,
matching the output format of the swagger_schema macro.
Example
def swagger_definitions do
%{
CreateUserRequest: ZoiPhoenixSwagger.schema_definition(@create_user_schema),
UpdateUserRequest: ZoiPhoenixSwagger.schema_definition(@update_user_schema)
}
endThe schema name is specified as the map key, allowing for clean, readable definitions.