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 warnings for optional parameters even when using property #888

Closed
davidwessman opened this issue Jun 13, 2023 · 2 comments
Closed
Labels

Comments

@davidwessman
Copy link
Contributor

Hello!

When I specify my return values like this:

          api(
            :POST,
            "/v2/namespace/credentials",
            "Generate new credentials"
          )
          returns(code: 200) do
            property(:username, String)
            property(:password, String)
          end
          def create
          end

and generate swagger, I still get warnings:

The parameter :username is optional but default value is not specified (use :default_value => ...)
The parameter :password is optional but default value is not specified (use :default_value => ...)

even though property are required by default. I also tried adding required: true but still get the errors.

It does generate the correct swagger file as far as I understand:

"responses": {
          "200": {
            "description": "OK",
            "schema": {
              "type": "object",
              "properties": {
                "username": {
                  "type": "string"
                },
                "password": {
                  "type": "string"
                }
              },
              "additionalProperties": false,
              "required": [
                "username",
                "password"
              ]
            }
          }
        },
@davidwessman
Copy link
Contributor Author

The @in_schema seems to be true and then it wont consider @param_description.required which would have returned true:

required_from_path? || (!@in_schema && @param_description.required)

@davidwessman
Copy link
Contributor Author

Fixed in 1.2.2, thank you @shev-vadim-net 🎉

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

No branches or pull requests

2 participants