cyprieng / swagger-parser

Give useful informations about your swagger files
MIT License
62 stars 59 forks source link

is allOf supported? #24

Open ghost opened 8 years ago

ghost commented 8 years ago

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: "yoshi@yoshi.com"
      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

cyprieng commented 8 years ago

It's not supported yet, but thanks for the report. If you want to provide a PR it would be good.

ghost commented 8 years ago

additionalProperties is also not supported

    additionalProperties:
      $ref: "#/definitions/Yoshi"
flavianh commented 7 years ago

@pouledodue Feel free to submit a PR, we'll gladly have a look at it :)

jwg4 commented 6 years ago

@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?

jwg4 commented 6 years ago

PR #61 was merged so this issue may be solved.