question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

x-nullable not working for response primitives

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

5reactions
fearthecowboycommented, Jun 5, 2018

It’s possible that for responses that are primitive, we didn’t support x-nullable.

I’ll have to dig into it.

2reactions
calvaradoclcommented, Nov 25, 2020

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

AutoRest generating nullable boolean for method return type
According to this issue on autorest GitHub: x-nullable not working for response primitives, there is an issue with the autorest generators ...
Read more >
Add support for 'null' values in response. - Bitbucket
I found no way to overcome this. As a solution I see either supporting one of the 'x-nullable' kind of attributes in spec...
Read more >
543304 – @NonNull produces an error with arrays of primitives
No, I am really using javac from Java 7 and Lombok's NonNull annotation. Here is a test class which compiles with Java 7...
Read more >
Schema generation rules · GitBook - Goswagger.Io
Here are the rules that turn something into a pointer. structs; x-nullable , x-isnullable : explicit override to accept null values (otherwise not...
Read more >
AutoRest Extensions for OpenAPI 2.0 - Azure documentation
This is not a good choice when the parameter is provided from a source where the ... multiple primitive parameters into a composite...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found