swaggerconformance.apitemplates package¶
Module contents¶
This package provides templates which can be generated from a Swagger schema to represent parts of that schema which can later be filled in by generated values.
It also exposes the SwaggerParameter
interface, which is the type of
object that is passed to a ValueFactory
to generate values for.
-
class
swaggerconformance.apitemplates.
APITemplate
(client)[source]¶ Bases:
object
Template for an entire Swagger API.
-
endpoints
¶ Mapping of the endpoints of this API to their operations.
Return type: dict(str, dict(str, OperationTemplate))
-
template_operations
()[source]¶ All operations of the API across all endpoints.
Return type: iter(OperationTemplate)
-
-
class
swaggerconformance.apitemplates.
OperationTemplate
(app, operation)[source]¶ Bases:
object
Template for an operation on an endpoint.
Parameters: - app (pyswagger.core.App) – The app representing the API.
- operation (pyswagger.spec.v2_0.objects.Operation) – The definition of the operation in the API schema.
-
hypothesize_parameters
(value_factory)[source]¶ Generate hypothesis fixed dictionary mapping of parameters.
Parameters: value_factory (swaggerconformance.valuetemplates.ValueFactory) – Factory to generate strategies for values.
-
operation
¶ The actual API operation this template represents.
Return type: pyswagger.spec.v2_0.objects.Operation
-
parameters
¶ Mapping of the names of the parameters to their templates.
Return type: dict(str, ParameterTemplate)
-
class
swaggerconformance.apitemplates.
ParameterTemplate
(swagger_definition)[source]¶ Bases:
object
Common class for Swagger API operation parameters.
Parameters: swagger_definition (SwaggerParameter) – The swagger spec portion defining the parameter. -
hypothesize
(value_factory)[source]¶ Generate a hypothesis strategy representing this parameter.
Parameters: value_factory (swaggerconformance.valuetemplates.ValueFactory) – Factory to generate strategies for values.
-
items
¶ The children of this parameter if it’s an array -
None
otherwise.Return type: ParameterTemplate or None
-
properties
¶ The children of this parameter if it’s a dict -
None
otherwise.Return type: dict(str, ParameterTemplate) or None
-
-
class
swaggerconformance.apitemplates.
SwaggerParameter
(swagger_app, swagger_definition)[source]¶ Bases:
object
Wrapper around a parameter to pass to an operation on an endpoint.
This may be a
Parameter
or aSchema
object, either passed directly as a parameter to an operation as a child of one.Since a Swagger
Items
object may be a child of aParameter
, treat that as a parameter as well since it’s sufficiently similar we don’t care about the distinction.Items
don’t have names though, so be careful of that.Parameters: - swagger_app (pyswagger.core.App) – The API the parameter is part of.
- swagger_definition (pyswagger.spec.v2_0.objects.Parameter or pyswagger.spec.v2_0.objects.Items or pyswagger.spec.v2_0.objects.Schema) – The swagger spec definition of this parameter.
-
additionalProperties
¶ Whether this paramater is a dict that accepts arbitrary entries.
Return type: bool
-
items
¶ The Parameter elements of this Parameter if it’s an array.
Return type: SwaggerParameter or None
-
location
¶ The location of this parameter - e.g. ‘header’ or ‘body’, or
None
if not a top-level parameter.Return type: str or None
-
properties
¶ The dict of Parameter elements of this Parameter if it’s an object.
Return type: dict(str, SwaggerParameter) or None