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

OpenAPI: Required method parameters become nullable with /GenerateOptionalParameters:true #1470

Closed
bkoelman opened this issue Feb 18, 2024 · 1 comment

Comments

@bkoelman
Copy link
Member

When adding the /GenerateOptionalParameters:true option in NSwag generated clients, the request body parameter becomes nullable. For example:

public virtual async Task<ApiResponse<CountryPrimaryResponseDocument>> PatchCountryAsync(string id,
    IDictionary<string, string?>? query = null, CountryPatchRequestDocument? body = null,
    CancellationToken cancellationToken = default(CancellationToken))

This is incorrect because it always fails with HTTP 422.

The OAS for this method looks correct, as far as I'm aware:

"requestBody": {
  "description": "The attributes and relationships of the country to update. Omitted fields are left unchanged.",
  "content": {
    "application/vnd.api+json": {
      "schema": {
        "allOf": [
          {
            "$ref": "#/components/schemas/countryPatchRequestDocument"
          }
        ]
      }
    }
  }
}

I've opened this issue to investigate why this is happening.

@bkoelman
Copy link
Member Author

Closing, this was fixed in #1507.

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

No branches or pull requests

1 participant