Skip to content

fix: handle inf and nan number defaults - #1532

Open
takinanton wants to merge 1 commit into
openapi-generators:mainfrom
takinanton:fix-non-finite-number-defaults
Open

takinanton wants to merge 1 commit into
openapi-generators:mainfrom
takinanton:fix-non-finite-number-defaults

Conversation

@takinanton

Copy link
Copy Markdown

A yaml spec with default: .inf on a number makes the model emit upper: float | Unset = inf and importing it dies with NameError. Same for nan and for string defaults like "-Infinity". On an integer .inf crashes the whole generator with OverflowError.

upper: {type: number, default: .inf}
big: {type: integer, default: .inf}

Non finite floats now render as float("inf") and friends. Ints reject them with the usual "Invalid int value" warning. Added functional tests for both. They fail on main and pass here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant