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

Autorest does not generate the client with null values #4938

Open
w4mhi opened this issue Apr 4, 2024 · 0 comments
Open

Autorest does not generate the client with null values #4938

w4mhi opened this issue Apr 4, 2024 · 0 comments
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that

Comments

@w4mhi
Copy link

w4mhi commented Apr 4, 2024

I have the following section in swagger:

    "/api/configuration/person": {
      "get": {
        "tags": [
          "PersonInformation"
        ],
        "summary": " (Auth policies: Reader)",
        "operationId": "GetPersonInformation",
        "parameters": [
          {
            "name": "lastname",
            "in": "query",
            "description": "'lastname' is optional parameter.",
            "allowEmptyValue": true,
	        "required": false,
            "schema": {
              "type": "string",
              "nullable": true
            }
          },
          {
            "name": "api-version",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "content": {
              "application/json": {
                "schema": {
                  "type": "array",
                  "items": {
                    "$ref": "#/components/schemas/GetPersonInformation"
                  }
                }
              }
            }
          },
          "400": {
            "description": "Bad Request"
          },
          "404": {
            "description": "Not Found"
          },
          "500": {
            "description": "Server Error"
          }
        }
      }
    },

This swagger comes from the API definition:

[HttpGet]
[Authorize(Policy = "Reader")]
[Route("configuration/drops", Name = nameof(GetPersonInformation))]
[SwaggerResponse(StatusCodes.Status200OK, type: typeof(IEnumerable<PersonInformation>))]
[SwaggerResponse(StatusCodes.Status400BadRequest)]
[SwaggerResponse(StatusCodes.Status404NotFound)]
[SwaggerResponse(StatusCodes.Status500InternalServerError)]
    public async Task\<IActionResult\> GetPersonInformation(
        CancellationToken cancellationToken,
        string lastname = null)

I ran autorest with parameters:
autorest --input-file=swagger.json --csharp --add-credentials --verbose

AutoRest code generation utility \[cli version: 3.7.1; node: v18.18.0\]
(C) 2018 Microsoft Corporation.
https://aka.ms/autorest
info    | AutoRest core version selected from configuration: ^3.2.0.
info    |    Loading AutoRest core      '.autorest@autorestcore@3.9.7\nodemodules@autorest\core\dist' (3.9.7)

The result is this:

public virtual async Task\<Response\> GetPersonInformation(string lastname, RequestContext context)

I expected (in previous version was correctly generated):

public virtual async Task\<Response\> GetPersonInformation(string lastname = null, RequestContext context = null)

Does anyone have a suggestion? What am I missing? Thank you!

@w4mhi w4mhi added the question The issue doesn't require a change to the product in order to be resolved. Most issues start as that label Apr 4, 2024
@microsoft-github-policy-service microsoft-github-policy-service bot added the customer-reported Issues that are reported by GitHub users external to the Azure organization. label Apr 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
customer-reported Issues that are reported by GitHub users external to the Azure organization. question The issue doesn't require a change to the product in order to be resolved. Most issues start as that
Projects
None yet
Development

No branches or pull requests

1 participant