Hello,
I'm working on an API with Swashbuckle and Autorest for it's clients. Currently all the responses that are primitive types (int, bool) become nullable (int? or bool?), but they shouldn't be like that.
I applied a filter before in order to correct the same issue on my entities with x-nullable, but for some reason is not working on the return types.
Is there any other way to achieve this?
Example code:
/api/Alert/Remove:
delete:
tags:
- Alert
operationId: AlertRemove
consumes: []
produces:
- application/json
parameters:
- name: id
in: query
required: true
type: string
format: uuid
responses:
'200':
description: Success
schema:
type: boolean
x-nullable: false
Autorest generated client method
public static bool? AlertRemove(this IAlertsClient operations, System.Guid id)
{
return operations.AlertRemoveAsync(id).GetAwaiter().GetResult();
}
Hi, I got same issue.
I even tried to put: "default: 0" in int type, but it don't work also.
It's possible that for responses that are primitive, we didn't support x-nullable.
I'll have to dig into it.
Hi @fearthecowboy, any updates on this?
Are there any workarounds for this? I've stepped through the code, but can't seem to find where I should make the change.
There won't be a fix for the current v2 generator -- the v3 generators are just around the corner, and won't do this.
Hi, I just wanted to check if this was on Autorest's roadmap for the next months, because I'm currently using the last version of the --v3 generator and still the primitive types are generated as nullables.
Most helpful comment
It's possible that for responses that are primitive, we didn't support
x-nullable.I'll have to dig into it.