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

[REQUEST] Using oneOf, anyOf or AllOf with inline schemas #743

Open
3 tasks
kheraankit opened this issue Apr 15, 2024 · 1 comment
Open
3 tasks

[REQUEST] Using oneOf, anyOf or AllOf with inline schemas #743

kheraankit opened this issue Apr 15, 2024 · 1 comment

Comments

@kheraankit
Copy link

Is your feature request related to a problem? Please describe.

We want to leverage oneOf in some of our API responses. The way these seem to function is one needs to first define these schemas part of the openapi_specs config that is supplied via swagger_helper.rb. This doesn't seem to support the schemas that are defined inline within the spec or in some ruby files. It expects these schemas to be present as part of the config.openapi_specs = { openapi: '3.0.1', ... schemas: {} } .

      parameter name: :blog, in: :body, schema: {
          oneOf: [
            { '$ref' => '#/components/schemas/blog' },
            { '$ref' => '#/components/schemas/flexible_blog' }
          ]
        }

Describe the solution you'd like

Is there a way to use them in the following manner

      schema:  {
          oneOf: [
            { '$ref' =>  { type: :object, properties : { ... } }},
            { '$ref' => { type: :object, properties : { ... } }}
          ]
        }

What support could we give you, so you could implement this yourself?

Please tell us how could we help you implement this feature, so you could
become a contributor. Our time is limited, so it's unlikely that we will
be able to implement this ourselves, but we will try to help you

Describe alternatives you've considered

A clear and concise description of any alternative solutions or features you've considered.

Additional context

Add any other context or screenshots about the feature request here.

Relates to which version of OAS (OpenAPI Specification)

  • OAS2
  • OAS3
  • OAS3.1
@kalorz
Copy link

kalorz commented Apr 26, 2024

@kheraankit I think the issue here is that the inline schemas must be provided without the $ref key:

schema:  {
          oneOf: [
            { type: :object, properties : { ... } },
            { type: :object, properties : { ... } }
          ]
        }

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

No branches or pull requests

2 participants