Exemplo n.º 1
0
    def compare_schemas(schema1, schema2):
        schema1 = OrderedDict(schema1)
        schema2 = OrderedDict(schema2)
        ignore = ['info', 'host', 'schemes', 'basePath', 'securityDefinitions']
        for attr in ignore:
            schema1.pop(attr, None)
            schema2.pop(attr, None)

        # print diff between YAML strings because it's prettier
        assert_equal(yaml_sane_dump(schema1, binary=False), yaml_sane_dump(schema2, binary=False))
Exemplo n.º 2
0
def test_reference_schema(swagger_dict, reference_schema):
    swagger_dict = OrderedDict(swagger_dict)
    reference_schema = OrderedDict(reference_schema)
    ignore = ['info', 'host', 'schemes', 'basePath', 'securityDefinitions']
    for attr in ignore:
        swagger_dict.pop(attr, None)
        reference_schema.pop(attr, None)

    # print diff between YAML strings because it's prettier
    assert_equal(yaml_sane_dump(swagger_dict, binary=False),
                 yaml_sane_dump(reference_schema, binary=False))
Exemplo n.º 3
0
    def render(self, data, media_type=None, renderer_context=None):
        if 'openapi' in data or 'swagger' in data:
            if self.format == '.yaml':
                return yaml_sane_dump(data, False)
            elif self.format == '.json':
                return json.dumps(data)

        return super().render(data, media_type=media_type, renderer_context=renderer_context)
Exemplo n.º 4
0
    def render(self, data, media_type=None, renderer_context=None):
        if "openapi" in data or "swagger" in data:
            if self.format == ".yaml":
                return yaml_sane_dump(data, False)
            elif self.format == ".json":
                return json.dumps(data)

        return super().render(data,
                              media_type=media_type,
                              renderer_context=renderer_context)