swaggerconformance.schema 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 Primitive
interface, which is the type of object that is
passed to a StrategyFactory
to generate values for.
-
class
swaggerconformance.schema.
Api
(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, schema.Operation))
-
operation
(operation_id)[source]¶ Access a single operation by its unique operation ID.
Return type: schema.Operation
-
operations
()[source]¶ All operations of the API across all endpoints.
Return type: Generator(schema.Operation)
-
-
class
swaggerconformance.schema.
Operation
(operation)[source]¶ Bases:
object
Template for an operation on an endpoint.
Parameters: operation (pyswagger.spec.v2_0.objects.Operation) – The definition of the operation in the API schema. -
parameters
¶ Mapping of the names of the parameters to their templates.
Return type: dict(str, Parameter)
-
parameters_strategy
(value_factory)[source]¶ Generate hypothesis fixed dictionary mapping of parameters.
Parameters: value_factory (strategies.StrategyFactory) – Factory to generate strategies for values.
-
-
class
swaggerconformance.schema.
Parameter
(swagger_definition)[source]¶ Bases:
object
A Swagger API operation parameter.
Parameters: swagger_definition (schema.Primitive) – The swagger spec portion defining the parameter. -
strategy
(value_factory)[source]¶ Generate a hypothesis strategy representing this parameter.
Parameters: value_factory (strategies.StrategyFactory) – Factory to generate strategies for values.
-
-
class
swaggerconformance.schema.
Primitive
(swagger_definition)[source]¶ Bases:
object
Wrapper around a primitive in a swagger schema.
This may be a Parameter or a Schema Swagger 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 a Parameter or schema, treat that the same 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_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 Primitive is a dict that accepts arbitrary entries.
Return type: bool or None
-
location
¶ The location of this Primitive - e.g. ‘header’ or ‘body’, or
None
if not a top-level primitive.Return type: str or None
-
maxProperties
¶ The maximum number of properties in this Primitive if it’s a dict.
Return type: int or None
-
minProperties
¶ The minimum number of properties in this Primitive if it’s a dict.
Return type: int or None
-
pattern
¶ The regex pattern for this Primitive.
Return type: string or None
-
properties
¶ The dict of Primitive elements of this Primitive if it’s an object.
Return type: dict(str, Primitive) or None
-