swagger-parser
swagger-parser copied to clipboard
is allOf supported?
my swagger.yml contains:
definitions:
User:
type: "object"
required:
- "email"
- "uid"
- "password"
- "username"
properties:
uid:
type: "string"
description: "Usually a UUID"
example: "234"
# readOnly: true
email:
type: "string"
example: "[email protected]"
password:
type: "string"
example: "3X8(ISU!!"
username:
type: "string"
example: "yoshi"
minLength: 1
ExtendedErrorModel:
allOf:
- $ref: "#/definitions/User"
- type: "object"
required:
- "rootCause"
properties:
rootCause:
type: "string"
and it chokes on
self = <swagger_parser.swagger_parser.SwaggerParser object at 0x110a8f590>
prop_spec = {'allOf': [{'$ref': '#/definitions/User', 'x-scope': ['']}, {'properties': {'rootCause': {'type': 'string'}}, 'required': ['rootCause'], 'type': 'object'}]}
def _example_from_complex_def(self, prop_spec):
"""Get an example from a property specification.
In case there is no "type" key in the root of the dictionary.
Args:
prop_spec: property specification you want an example of.
Returns:
An example.
"""
if 'schema' in prop_spec and 'type' not in prop_spec['schema']:
definition_name = self.get_definition_name_from_ref(prop_spec['schema']['$ref'])
if self.build_one_definition_example(definition_name):
return self.definitions_example[definition_name]
> elif prop_spec['schema']['type'] == 'array': # Array with definition
E KeyError: 'schema'
example comes from here
It's not supported yet, but thanks for the report. If you want to provide a PR it would be good.
additionalProperties is also not supported
additionalProperties:
$ref: "#/definitions/Yoshi"
@pouledodue Feel free to submit a PR, we'll gladly have a look at it :)
@flavianh It looks like there is already a PR waiting for approval here: https://github.com/Trax-air/swagger-parser/pull/61 Is this PR likely to be merged? Is there anything I can do to help?
PR #61 was merged so this issue may be solved.