swaggerpy.processors module
Swagger processors enrich and validate the Swagger data model.
This can be to make templating easier, or ensure values required for a particular use case (such as ensuring that description and summary fields exist)
- class swaggerpy.processors.FlatenningProcessor[source]
Bases:
SwaggerProcessor
Flattens model and property dictionaries into lists.
Mustache requires a regular schema.
- process_api_declaration(resources, resource, context)[source]
Post process a resource object.
This is parsed from a .json file reference by a resource listing’s ‘api’ array.
- Parameters
resources – Resource listing object
resource – resource object.
context (ParsingContext) – Current context in the API.
- process_model(resources, resource, model, context)[source]
Post process a model from a resources model dictionary.
- Parameters
resources – Resource listing object
resource – resource object.
model – Model object.
context (ParsingContext) – Current context in the API.
- class swaggerpy.processors.ParsingContext[source]
Bases:
object
Context information for parsing.
This object is immutable. To change contexts (like adding an item to the stack), use the next() and next_stack() functions to build a new one.
- exception swaggerpy.processors.SwaggerError(msg, context, cause=None)[source]
Bases:
Exception
Raised when an error is encountered mapping the JSON objects into the model.
- class swaggerpy.processors.SwaggerProcessor[source]
Bases:
object
Post processing interface for Swagger API’s.
This processor can add fields to model objects for additional information to use in the templates.
- apply(resources)[source]
Apply this processor to a loaded Swagger definition.
- Parameters
resources (dict) – Top level Swagger definition.
- process_api_declaration(resources, resource, context)[source]
Post process a resource object.
This is parsed from a .json file reference by a resource listing’s ‘api’ array.
- Parameters
resources – Resource listing object
resource – resource object.
context (ParsingContext) – Current context in the API.
- process_error_response(resources, resource, api, operation, error_response, context)[source]
Post process an errorResponse on an operation.
- Parameters
resources – Resource listing object
resource – resource object.
api – API object
operation – Operation object.
error_response – Response object.
context (ParsingContext) – Current context in the API.
- process_model(resources, resource, model, context)[source]
Post process a model from a resources model dictionary.
- Parameters
resources – Resource listing object
resource – resource object.
model – Model object.
context (ParsingContext) – Current context in the API.
- process_operation(resources, resource, api, operation, context)[source]
Post process an operation on an api.
- Parameters
resources – Resource listing object
resource – resource object.
api – API object
operation – Operation object.
context (ParsingContext) – Current context in the API.
- process_parameter(resources, resource, api, operation, parameter, context)[source]
Post process a parameter on an operation.
- Parameters
resources – Resource listing object
resource – resource object.
api – API object
operation – Operation object.
parameter – Parameter object.
context (ParsingContext) – Current context in the API.
- process_property(resources, resource, model, prop, context)[source]
Post process a property from a model.
- Parameters
resources – Resource listing object
resource – resource object.
model – Model object.
prop – Property object.
context (ParsingContext) – Current context in the API.
- process_resource_api(resources, resource, api, context)[source]
Post process entries in a resource’s api array
- Parameters
resources – Resource listing object
resource – resource object.
api – API object
context (ParsingContext) – Current context in the API.
- process_resource_listing(resources, context)[source]
Post process a resources.json object.
- Parameters
resources – ResourceApi object.
context (ParsingContext) – Current context in the API.
- process_resource_listing_api(resources, listing_api, context)[source]
Post process entries in a resource.json’s api array.
- Parameters
resources – Resource listing object
listing_api – ResourceApi object.
context (ParsingContext) – Current context in the API.
- class swaggerpy.processors.WebsocketProcessor[source]
Bases:
SwaggerProcessor
Process the WebSocket extension for Swagger
- process_operation(resources, resource, api, operation, context)[source]
Post process an operation on an api.
- Parameters
resources – Resource listing object
resource – resource object.
api – API object
operation – Operation object.
context (ParsingContext) – Current context in the API.
- process_resource_api(resources, resource, api, context)[source]
Post process entries in a resource’s api array
- Parameters
resources – Resource listing object
resource – resource object.
api – API object
context (ParsingContext) – Current context in the API.