Skip to content

[REQ] Support unsigned integer format specifiers #22031

@BatmanAoD

Description

@BatmanAoD

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

I have an OpenAPI schema that uses format: uint64 for some integer values. The Rust generator (and probably other languages as well) uses i32 to represent these.

Describe the solution you'd like

These should be represented as u64 in Rust and the analogous type in other languages that support 64-bit unsigned integers.

Describe alternatives you've considered

  • The generator could take a "maximally permissive" approach to unrecognized format specifiers; that is, it could treat all unrecognized formats as int64. This would result in i64, which, while still not strictly correct, would be preferable to i32, since it vastly reduces the range of unsupported values.
  • The generator could simply exit with an error if there are unrecognized format specifiers. This would be inconvenient, but would at least prevent generating incorrect code.

Additional context

This was previously requested for C++ here: #5010

However, it was closed with this comment

Unfortunately there are no unsigned in OAS.

This was true at the time, but the format specifier now has a "registry" of official-but-non-required values: https://spec.openapis.org/registry/format/

Unsigned integers are listed there, so I think it is now appropriate for the tooling to support them.

Note that Rust's poem crate generates OpenAPI schemas that use the uint64 format: poem-web/poem#760

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions