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

Provide a way to optionally not send a request body if optional #4807

Open
notaphplover opened this issue Feb 15, 2024 · 0 comments
Open

Provide a way to optionally not send a request body if optional #4807

notaphplover opened this issue Feb 15, 2024 · 0 comments

Comments

@notaphplover
Copy link

Content & configuration

Swagger/OpenAPI definition:

openapi: 3.1.0
info:
 title: One game API
 version: "1.0"
servers:
 - url: http://127.0.0.1:8000
   description: Local development server
components:
 schemas:
   LoginAuthCreateQueryV2:
     $id: https://onegame.schemas/api/v2/auth/login-auth-create-query.json
     title: LoginAuthCreateQueryV2
     type: object
     additionalProperties: false
     properties:
       email:
         type: string
       kind:
         const: login
         type: string
       password:
         type: string
     required:
       - email
       - kind
       - password
   AuthV2:
     $id: https://onegame.schemas/api/v2/auth/auth.json
     title: AuthV2
     type: object
     additionalProperties: false
     properties:
       accessToken:
         type: string
       refreshToken:
         type: string
     required:
       - accessToken
       - refreshToken
paths:
 /v2/auth:
   post:
     summary: Create an authorization token
     operationId: createAuthV2
     requestBody:
       content:
         application/json:
           schema:
             $ref: https://onegame.schemas/api/v2/auth/login-auth-create-query.json
       required: false
     responses:
       "200":
         description: Authorization token created
         content:
           application/json:
             schema:
               $ref: https://onegame.schemas/api/v2/auth/auth.json
     tags:
       - Auth
tags:
 - name: Auth
   description: Authorization management operations

Swagger-Editor configuration options:

// Not relevant

Is your feature request related to a problem?

There doesn't seem to be a way to avoid sending a request body in case it's optional.

Describe the solution you'd like

I would love to have a way to disable the request body field in order to not to send it when the request body is optional.
Maybe a check box could be added (enabled by default) so clicking it would disable the textarea. No body would be sent in this case.

Describe alternatives you've considered

Almost any other way to allow not no send a request body in case an endpoint has an optional request body would be good enough.

Additional context

https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#request-body-object

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

1 participant