Closed
Description
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.