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

Swagger 2: Components Response required: true is not valid swagger #941

Open
simonireilly opened this issue Sep 6, 2024 · 2 comments
Open

Comments

@simonireilly
Copy link

simonireilly commented Sep 6, 2024

Description

Path parameters are singleton resources, and have the schema of required: true to specify their _require_ment

paths:
  /users/{userId}:
    get:
      summary: Get a user by ID
      parameters:
        - in: path
          name: userId
          schema:
            type: integer
          required: true
          description: Numeric ID of the user to get

Schema response components and request bodies use the required: [] syntax to specify which of the fields in their object structure must be provided.

Assertion

The popular redocly CLI replaced the depreacted swagger cli and can be used to lint the produced swagger 2.

npx @redocly/cli lint doc/apidoc/schema_swagger_json.json 

Benefit

Once there are far fewer errors generated in the swagger 2 file, the errors which are important for user action will be far easier to see, and act upon.

Fix

When generating swagger from ApiPie remove the required: true generated output from the JSON for request bodies and response bodies, but preserve the array definition

@mathieujobin
Copy link
Collaborator

Thank you for opening this well described issue.

Can you open a Pull request with the necessary changes?

@jaynetics
Copy link

it seems to be as easy as removing this line, but i'm a bit unsure what is right here because the official json schema of 2.0 says a boolean is valid...

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