swaggerconformance.strategies package¶
Submodules¶
Module contents¶
This package provides access to two main classes of objects:
StrategyFactoryfor generatingPrimitiveStrategyinstances matching the parameter values defines by a parameter entry in a swagger schema. This can be inherited from to generate newPrimitiveStrategyinstances matching custom parameters in a user’s schema.- The
PrimitiveStrategyitself and child classes used to generate hypothesis strategies for generating parameter values with certain constraints. Again, users may create newPrimitiveStrategysubclasses to define their own new value types.
-
class
swaggerconformance.strategies.StrategyFactory[source]¶ Bases:
objectFactory for building
PrimitiveStrategyfrom swagger definitions.-
produce(swagger_definition)[source]¶ Create a template for the value specified by the definition.
Parameters: swagger_definition (schema.Primitive) – The schema of the parameter to create. Return type: PrimitiveStrategy
-
register(type_str, format_str, creator)[source]¶ Register a function to generate
PrimitiveStrategyinstances for this type and format pair.The function signature of the
creatorparameter must be:def fn(schema.Primitive,StrategyFactory) ->PrimitiveStrategyParameters:
-
register_type_default(type_str, creator)[source]¶ Register a function to generate
PrimitiveStrategyinstances for this type paired with any format with no other registered creator.The function signature of the
creatorparameter must be:def fn(schema.Primitive,StrategyFactory) ->PrimitiveStrategyParameters: - type_str (str) – The Swagger schema type to register for.
- creator (callable) – The function to create a
PrimitiveStrategy.
-
-
swaggerconformance.strategies.string_primitive_strategy(swagger_definition, factory)[source]¶ Function for creating an appropriately formatted string value depending on the location of the string parameter.
Parameters: swagger_definition (schema.Primitive) – The schema of the parameter to create. Return type: PrimitiveStrategy