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

[BUG] [csharp-netcore] Wrong type for integer of range 0-4294967295 #14481

Closed
5 of 6 tasks
arvindpdmn opened this issue Jan 18, 2023 · 0 comments · Fixed by #14891
Closed
5 of 6 tasks

[BUG] [csharp-netcore] Wrong type for integer of range 0-4294967295 #14481

arvindpdmn opened this issue Jan 18, 2023 · 0 comments · Fixed by #14891

Comments

@arvindpdmn
Copy link

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When integer range is specified as 0-4294967295, generated code uses the type "int". Instead "uint" should be used. Compilation error occurs on the line: if (this.ServiceId > (int)4294967295)

openapi-generator version

Version used is 6.2.1. Did not test against the latest commit on the master branch.

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  version: '1.0.0'
  title: 'Use uint rather than int'
paths: {}
components:
  schemas:
    ServiceDetails:
      type: object
      properties:
        serviceId:
          $ref: '#/components/schemas/Uint32'
    Uint32:
      type: integer
      minimum: 0
      maximum: 4294967295 #(2^32)-1
Generation Details
java -jar C:\openapi-generator-cli.jar generate  -i C:\IntegerRange.yaml -g csharp-netcore -o C:\IntegerRange --additional-properties=targetFramework=net6.0 --additional-properties=packageName=Com.Example --skip-validate-spec
Steps to reproduce

Just run the command above and compile the generated model file. We will see the error.

Related issues/PRs

None

Suggest a fix

Check range and select "uint" if minimum value is 0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant