Skip to content

Decimal properties are not generated correctly in OpenAPI 3.0 #64471

@thomasvdb

Description

@thomasvdb

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

When configuring our .NET 10 project to generate OpenAPI documents of version 3.0, the OpenAPI schema for decimal properties seems to be incorrect:

"temperatureC": {
  "pattern": "^-?(?:0|[1-9]\\d*)(?:\\.\\d+)?$",
  "format": "double"
}

We use version 3.0 as we later on want to import these OpenAPI documents in Azure API Management which doesn't support the newer OpenAPI versions.

However, Azure API Management ignores this decimal field because (I think) according to the OpenAPI version 3.0 specification:

  1. The schema is missing the required type: "number" property
  2. The pattern property is only valid for type: "string", not numeric types

Previously with the Swashbuckle library, the property was outputted as

"temperatureC": {
  "type": "number",
  "format": "double"
}

which was imported correctly in Azure API Management.

Expected Behavior

Use the correct OpenAPI 3.0 specification for decimal properties if the project is configured as such.

"temperatureC": {
  "type": "number",
  "format": "double"
}

Steps To Reproduce

Repro project

Exceptions (if any)

No response

.NET Version

10.0.100

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-minimalIncludes minimal APIs, endpoint filters, parameter binding, request delegate generator etcfeature-openapi

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions