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

Non-intuitive oneOf in the rendered documentation #9055

Closed
xeppaka opened this issue Jul 24, 2023 · 3 comments
Closed

Non-intuitive oneOf in the rendered documentation #9055

xeppaka opened this issue Jul 24, 2023 · 3 comments

Comments

@xeppaka
Copy link

xeppaka commented Jul 24, 2023

Q&A (please complete the following information)

  • OS: Linux
  • Browser: Chromium
  • Version: 114.0.5735.198
  • Method of installation: online
  • Swagger-UI version: 5.1.3
  • Swagger/OpenAPI version: OpenAPI 3.1.0

Content & configuration

Swagger/OpenAPI definition:

openapi: 3.1.0
info:
  title: Test API
  version: '0.0.1'
paths:
  /data/test:
    post:
      tags:
      - Test API
      requestBody:
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/Input'
        required: true
      responses:
        '200':
          description: OK
      security:
      - httpAuth: []

components:
  schemas:
    Input:
      oneOf:
      - $ref: '#/components/schemas/InputOne'
      - $ref: '#/components/schemas/InputTwo'
      - $ref: '#/components/schemas/InputThree'
      discriminator:
        propertyName: vv
        mapping:
          INPUT_ONE: '#/components/schemas/InputOne'
          INPUT_TWO: '#/components/schemas/InputTwo'
          INPUT_THREE: '#/components/schemas/InputThree'
    InputOne:
      required: 
        - somefield
      type: object
      properties: 
        somefield: 
          type: string
    InputTwo:
      required: 
        - somefield
      type: object
      properties: 
        somefield: 
          type: string
    InputThree:
      required: 
        - somefield
      type: object
      properties: 
        somefield: 
          type: string
  securitySchemes:
    httpAuth:
      type: http
      scheme: bearer

Swagger-UI configuration options:

SwaggerUIBundle({
    urls: [
      { url: "api-private/test-api.yaml", name: "test-api" }
    ],
    dom_id: '#swagger-ui',
    deepLinking: true,
    presets: [
      SwaggerUIBundle.presets.apis,
      SwaggerUIStandalonePreset
    ],
    plugins: [
      SwaggerUIBundle.plugins.DownloadUrl
    ],
    layout: "StandaloneLayout",
    validatorUrl: "none"
  });

Screenshots

Screenshot_1

How can we help?

Hi, we updated to the new SwaggerUI version and from our point of view the rendering of oneOf objects is not intuitive for documentation reader. The #1, #2, #3 references from the screenshot above looks a bit weird... Is it possible to use mapping value names instead of #1, #2, #3 or make it at least the same way as it was before? Like that:

oneOf -> InputOne
      -> InputTwo
      -> InputThree
@xeppaka xeppaka closed this as completed Jul 24, 2023
@xeppaka xeppaka reopened this Jul 24, 2023
@BertSvensson
Copy link

try adding a "title" maybe?

InputOne:
      title: InputOne
      required: 
        - somefield
      type: object
      properties: 
        somefield: 
          type: string

@xeppaka
Copy link
Author

xeppaka commented Aug 17, 2023

try adding a "title" maybe?

InputOne:
      title: InputOne
      required: 
        - somefield
      type: object
      properties: 
        somefield: 
          type: string

Looks better after adding title. Thanks for the suggestion!

@xeppaka xeppaka closed this as completed Aug 17, 2023
@gustaf-annotell
Copy link

Adding a title works, but it gets very wordy when you add it in a lot of places.

Why isn't a title generated automatically (like it was previous to 3.1.0)?

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

3 participants