Skip to content

Inline elements in allOf: array  #848

Closed

Description

@jeff9finger

I have been studying the open api spec and swagger-codegen projects for the constraints on allOf:

It appears that swagger-codegen (language is java) only recognizes the last inline element of an allOf: array. I have not found a statement in this spec or code in swagger-codegen that specifies this constraint.

So, I'm asking... Can the allOf: array be multiple inline elements? If I create a spec that has more than 1 inline element, it appears that only the last one is recognized.

FYI: This came up in trying to define a discriminator for the inline object.

Example:

definitions:

  Object:
    allOf:
      - $ref: '#/definitions/SomeOtherObject'
      - type: object
        discriminator: object_type0
        required:
          - object_type0
        properties:          
          object_type0:
            type: string
          name:
            type: string
      - type: object
        discriminator: object_type1
        required:
          - object_type1
        properties:          
          object_type1:
            type: string
          name:
            type: string

Is Object supposed to contain all the properties from both inline objects? And if so, how are the discriminator fields handled?

Activity

  1. webron commented on Nov 21, 2016

    @webron
    Member

    allOf is an array of Schema Objects, whether referenced or defined inline. allOf itself can be used inline wherever the Schema Object is used, regardless of its location.

    The spec doesn't take into account the use case you provided here, and it's up to the tooling to decide whether to support it or not. I would expect them not to, mostly because I don't see the use for it.

  2. handrews commented on Feb 24, 2020

    @handrews
    Member

    More than three years since answer with no further comments. I'm guessing this is safe to close ;P

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions