Skip to content

Support x-propertyNames in OpenAPI 3.0 #1584

@indietyp

Description

@indietyp

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

OpenAPI 3.0 does not natively support the full set of the JSON-Schema specification; notably, patternProperties and propertyNames are absent. Some tools instead use the x- prefix to support patternProperties and propertyNames in OpenAPI 3.0.

Describe the solution you'd like

Would it be possible for datamodel-code-generator to support x-patternProperties and x-propertyNames as well? It would be great as we currently have no way of upgrading to 3.1 soon, but we would still like to benefit from pattern properties and properly typed property names.

Describe alternatives you've considered

There is no real alternative; the model currently generated is just empty, which is kind of valid, as in it will ignore any patterned properties.

Additional context

https://github.com/hashintel/hash/blob/990b911d4e9a166c4aff23844cf928945cd40159/apps/hash-graph/openapi/models/shared.json#L119-L149

A real-world snippet where we make use of both.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions