OpenAPITools / OpenAPITools/openapi-generator

[REQ][GO] Generating unsigned integers

Open
#7,393 0 comments 4 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Is your feature request related to a problem? Please describe.

Hi everyone,

The Golang generator generates int32 and int64 according to the integer format specified in the OpenAPI spec. Could it be possible to generate unsigned integers when minimum is >= 0?

Consider the following:

      schema:
        type: integer
        example: 16318315
        minimum: 1

Could we generate a unit32 for this?

Describe the solution you'd like

Use the minimum constraint to generate unsigned integers.

Describe alternatives you've considered

If we really want unsigned integers, we have to adjust the generated code.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the Golang generator's handling of OpenAPI integer formats and trace how the minimum constraint is processed. Review the generator's existing tests for integer schemas, then verify that schemas with a nonnegative minimum produce the intended unsigned Go type without changing other integer cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, openapi
Domain
api, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.