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

NSwag should not generate an attribute with the default value for query parameters in OAS 3.0 #2010

Closed
klacol opened this issue Mar 10, 2019 · 2 comments

Comments

@klacol
Copy link

klacol commented Mar 10, 2019

We have a controller with this signature

public IHttpActionResult GetBuildingsWithHseq(string expand = null, bool deactivated = false)
{}

NSwag generates an OAS 3.0 file with the query param "deactivated" like this:

"/api/Hseq/Buildings": {
      "get": {
        "tags": [
          "Hseq"
        ],
        "summary": "Get a list of all buildings that have at minimum one HSEQ function attached",
        "operationId": "Hseq_GetBuildingsWithHseq",
        "parameters": [
          {
            "name": "expand",
            "in": "query",
            "description": "(optional) The csv list of properties to expand in result.",
            "schema": {
              "type": "string",
              "nullable": true
            },
            "x-position": 1
          },
          {
            "name": "deactivated",
            "in": "query",
            "description": "(optional) inclusive deactivated records.",
            "schema": {
              "type": "boolean"
            },
            "x-position": 2,
            "default": false
          }

This is not valid according to https://editor.swagger.io/ and https://speccy.io. A parameter has no attribute with the name "default". See also in the specification.

NSwag should not generate the attribute "default" for query parameters in OAS 3.

@klacol klacol changed the title Nswag should not generate an attribute with the default value for query paremeters in OAS 3.0 NSwag should not generate an attribute with the default value for query parameters in OAS 3.0 Mar 10, 2019
@markafox
Copy link

markafox commented Apr 30, 2019

the "default" attribute should be inside the "schema"

{
            "name": "deactivated",
            "in": "query",
            "description": "(optional) inclusive deactivated records.",
            "schema": {
              "type": "boolean",
              "default": false
            },
            "x-position": 2
          }

@anas2204
Copy link

I am facing the same issue. The "default" should be inside "schema" for query parameters.

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

No branches or pull requests

4 participants