Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

oneOf nested in an allOf prevents allOf from displaying all in v2.0.0-alpha.38 #641

Closed
trip-somers opened this issue Sep 12, 2018 · 6 comments · Fixed by #2576
Closed

oneOf nested in an allOf prevents allOf from displaying all in v2.0.0-alpha.38 #641

trip-somers opened this issue Sep 12, 2018 · 6 comments · Fixed by #2576

Comments

@trip-somers
Copy link

Before (v2.0.0-alpha.37):

screen shot 2018-09-12 at 5 26 53 pm

After (v2.0.0-alpha.38 -- missing Body.Order.Transaction):

screen shot 2018-09-12 at 5 27 27 pm

YAML:

    PaymentsRequestSale:
      title: Sale
      type: object
      required:
      - Header
      - Body
      properties:
        Header:
          $ref: '#/components/schemas/RequestHeaders'
        Body:
          title: Body
          allOf:
          - $ref: '#/components/schemas/Merchant'
          - $ref: '#/components/schemas/PaymentsOrderSale'

    PaymentsOrderSale:
      type: object
      required:
      - Order
      properties:
        Order:
          title: Sale
          description: A request to authorize and capture funds.
          allOf:
          - $ref: '#/components/schemas/PaymentMethod'
          - $ref: '#/components/schemas/TransactionRequestSale'

    PaymentMethod:
      oneOf:
      - $ref: '#/components/schemas/PaymentMethodByID'
      - $ref: '#/components/schemas/PaymentMethodByTokenSaveable'
      - $ref: '#/components/schemas/PaymentMethodByAccountSaveable'
      - $ref: '#/components/schemas/PaymentMethodByMasterPass'

    TransactionRequestSale:
      type: object
      required:
      - Transaction
      properties:
        Transaction:
          title: Sale Transaction
          allOf:
          - type: object
            required:
            - Amount
            - Type
            properties:
              Type:
                type: string
                enum:
                - Sale
              Amount:
                description: The amount in cents.
                type: integer
                example: 78953
              Currency:
                $ref: '#/components/schemas/Currency'
              SplitMerchant:
                description: The ID of the merchant to which funds should be split.
                type: integer
                nullable: true
                example: null
              SplitAmount:
                description: The amount in cents to split.
                type: integer
                nullable: true
                example: null
          - $ref: '#/components/schemas/TransactionRequest'

I looked over a diff on .38 vs .37, and I did not immediately see a cause for this. I can provide more detail if necessary.

@trip-somers trip-somers changed the title oneOf nested in an allOf is not displayed in v2.0.0-alpha.38 oneOf nested in an allOf prevents allOf from displaying all in v2.0.0-alpha.38 Sep 12, 2018
@trip-somers
Copy link
Author

Behavior confirmed in v2.0.0-alpha.39 as well.

@trip-somers
Copy link
Author

Behavior confirmed in v2.0.0-alpha.40.

@RomanHotsiy
Copy link
Member

@trip-somers Thanks for verifying.

I will look into this a bit later. Sorry for the delay.

@RomanHotsiy
Copy link
Member

Just a note for myself

Got able to minify the reproducible sample down to:

Main:
  title: Sale
  description: A request to authorize and capture funds.
  allOf:
  - $ref: '#/components/schemas/SchemaWithOneOfWithRefInside'
  - type: object
    properties:
      b:
        type: number
SchemaWithOneOfWithRefInside:
  oneOf:
  - $ref: "#/components/schemas/Anything"
Anything:
  type: object
  properties:
    a:
      type: string

Looks like oneOf hoisting doesn't resolve $ref which leads to using only #/components/schemas/Anything.
Have to dig it further.
Hopefully switching to all-deref will solve the issue.

@floggle
Copy link

floggle commented Dec 15, 2018

Also seems to happen with anyOf nested inside a allOf (2.0.0 rc0)

@anikitin
Copy link

Well, this pretty annoying issue preventing using the full power of the polymorphism in OpenAPI.
Any plans to fix it?

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

Successfully merging a pull request may close this issue.

4 participants