Skip to content
This repository was archived by the owner on Dec 25, 2024. It is now read-only.

Allows generators to ingest integers when type=number and format=float/double #427

Merged
merged 11 commits into from
Apr 20, 2024

Conversation

spacether
Copy link
Contributor

@spacether spacether commented Apr 19, 2024

Allows generators to ingest integers when type is number and format is float/double

  • A new command line arg was added: --ints-allowed-for-float-double-formats which defaults to false
    • in the next major release (>=5.0.0) this default value will be set to true by default to automatically conform with json schema
  • updated the 303 and 310 java and python clients to use that new generation option and sets it to true
  • python updated to allow int + floats in when type = integer because json schema requires that ints are allowed in and that was a bug in the python implementation. The java implementation does not have this bug.

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    mvn clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/generate_samples_configs/python*
    For Windows users, please run the script in Git BASH.

@@ -20,6 +20,7 @@ types: typing.FrozenSet[typing.Type] = frozenset({
{{/eq}}
{{#eq this "integer"}}
int,
float,
Copy link
Contributor Author

@spacether spacether Apr 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Per json schema, int + float should be allowed in for int types. The values will be checked to ensure that they are integer like.
In the future a flag could be added floatingTypesAllowedForTypeInteger to disallow float here in python and Float/Double in java
The original code only allowing in int here is a bug.

@spacether spacether changed the title Allows generators to ingest integers when type is number and format is float/double Allows generators to ingest integers when type=number and format=float/double Apr 20, 2024
@spacether spacether marked this pull request as draft April 20, 2024 00:38
@spacether spacether marked this pull request as ready for review April 20, 2024 01:08
@spacether spacether merged commit 3854585 into master Apr 20, 2024
5 checks passed
@spacether spacether deleted the feat_allows_ints_in_float_double branch April 20, 2024 20:07
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[REQ][python] Allow type: number format: float to ingest json integers
1 participant