swaggerconformance.codec module¶
Provides a codec for converting between JSON representations of objects and the objects themselves.
-
class
swaggerconformance.codec.
CodecFactory
[source]¶ Bases:
object
Produces codecs that encode objects as JSON and decode JSON back into objects.
-
produce
(swagger_definition, value)[source]¶ Construct an object with the given value, represented by the given schema portion using the registered type/format mappings.
Parameters: - swagger_definition (schema.Primitive) – The Swagger schema type to register for.
- value – The value to use to build the object - may be the
applicable portion of JSON after
json.loads
processing, or any supported input value for the relevant object.
-
register
(type_str, format_str, creator)[source]¶ Register a new creator for objects of the given type and format.
The
creator
parameter must be acallable
which takes the following paramters in order:schema.Primitive
- the Swagger schema for the object being handled.- The value to use to build the object - may be the applicable portion
of JSON after
json.loads
processing, or any supported input value for the relevant object. CodecFactory
- this factory, to be used to generate child objects if required, by calling theproduce
method on it.
Parameters:
-