OpenAPI.NET.OData icon indicating copy to clipboard operation
OpenAPI.NET.OData copied to clipboard

Reporting integer as number causes issues in client generators

Open sherlock1982 opened this issue 11 months ago • 4 comments

Reporting integer as number causes issues in client generators and invalid according to specification

Assemblies affected

Microsoft.OpenApi.OData.Reader 1.0.9

Steps to reproduce

Generate a specification.

Expected result

Integer numbers should be exposed as integer/int32

Actual result

Integer numbers will be exposed as number/int32

Additional detail

According to specification number/int32 is invalid. Caused by commit https://github.com/microsoft/OpenAPI.NET.OData/commit/95058a2ec66d68febb5a7980b5af5ded492d8fdc

This causes warning in openapi-generator and causes all integers to become doubles in NSwag

P.S. Ah I see what happened. Looks like there's an additional registry https://spec.openapis.org/registry/format/. These formats can be in the wild but are not in the specification at all. Therefore openapi-generator and NSwag doesn't support it.

But I think this library should be as close to specification as possible and use integer/int32 (exists in the spec) instead of number/int32 (doesn't exist in the spec but exists in optional registry)

Similar issue for #RicoSutter/NSwag/2880

sherlock1982 avatar Apr 28 '25 08:04 sherlock1982