Forum Discussion

pwangsom's avatar
pwangsom
Member
3 years ago

Why does SwaggerHub convert allOf to oneOf?

Here is my SwaggerHub link.

https://app.swaggerhub.com/apis/pwangsom/customer-api/2.0.5

 

I have created a NewBillingAddressInfo schema which comprises two inner schemas, NewBillingAddressHeader and NewBillingAddressBody. I used 'allOf' for composing both inner schemas together (line 2760).

NewBillingAddressHeader can be one of three different headers, so I used 'oneOf' to handle this (line 2693).

Also, NewBillingAddressBody can be one of two different bodies, I then used oneOf again (line 2636).

Therefore, I expect that NewBillingAddressInfo should compose of one NewBillingAddressHeader and one NewBillingAddressBody.

 

Here are my short schema definitions.

 

NewBillingAddressHeader:
oneOf:
- $ref: '#/components/schemas/NewBillingAddressIndyInfo'
- $ref: '#/components/schemas/NewBillingAddressOrgInfo'
- $ref: '#/components/schemas/NewBillingAddressIndyOrgInfo'

 

NewBillingAddressBody:
oneOf:
- $ref: '#/components/schemas/NewBillingAddressTh'
- $ref: '#/components/schemas/NewBillingAddressForiegn'

 

NewBillingAddressInfo:
allOf:
- $ref: '#/components/schemas/NewBillingAddressHeader'
- $ref: '#/components/schemas/NewBillingAddressBody'

 

However, SwaggerHub puts all of NewBillingAddressHeader and NewBillingAddressBody schemas together and uses the term 'oneOf' instead of 'allOf'. This does not guarantee that NewBillingAddressInfo should have one NewBillingAddressHeader and one NewBillingAddressBody.

 

Here is the example schema generated by SwaggerHub.

 

Please suggest to me, how to fix this issue.

 

Thank you

No RepliesBe the first to reply