Autorest: x-nullable not working for response primitives

Created on 25 May 2018  路  6Comments  路  Source: Azure/autorest

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();
            }

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.

All 6 comments

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.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kevinoid picture kevinoid  路  6Comments

olydis picture olydis  路  4Comments

pbolduc picture pbolduc  路  7Comments

SergeySagan picture SergeySagan  路  4Comments

vishrutshah picture vishrutshah  路  4Comments