Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe and support non-numeric floats #828

Merged
merged 11 commits into from
Jun 17, 2021

Conversation

JordonPhillips
Copy link
Contributor

This documents how the non-numeric floating point values NaN, Infinity, and -Infinity are handled in protocols. Essentially they are serialized as the protocol's strings with those values. Protocol tests have been added to each AWS protocol to assert that behavior.

Since JSON explicitly disallows these values, the jsonschema tooling doesn't enable them by default. This was also done because defaulting that behavior would be a breaking change.

Fixes #812

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Smithy floats and doubles are defined by IEEE754, which includes
support for a few non-numeric values. This adds information to the
AWS protocols docs on how to serialize them.
This adds support for non-numeric float values in jsonschema and
openapi. It is disabled by default because it makes the type
signature awful, and enabling it by default would be a backwards
incompatible change.
docs/source/1.0/spec/aws/aws-ec2-query-protocol.rst Outdated Show resolved Hide resolved
docs/source/1.0/spec/aws/aws-json.rst.template Outdated Show resolved Hide resolved
docs/source/1.0/spec/aws/aws-restxml-protocol.rst Outdated Show resolved Hide resolved
docs/source/1.0/spec/aws/aws-restjson1-protocol.rst Outdated Show resolved Hide resolved
docs/source/1.0/spec/aws/aws-query-protocol.rst Outdated Show resolved Hide resolved
@@ -106,6 +106,22 @@
return builder;
}

private void updateFloatFormat(Schema.Builder builder, JsonSchemaConfig config, String format) {
Copy link
Member

Choose a reason for hiding this comment

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

This is a bit unfortunate. I wonder if later we can rethink the divide between OpenAPI and JSON Schema converters.

docs/source/1.0/spec/aws/aws-ec2-query-protocol.rst Outdated Show resolved Hide resolved
docs/source/1.0/spec/aws/aws-ec2-query-protocol.rst Outdated Show resolved Hide resolved
docs/source/1.0/spec/aws/aws-ec2-query-protocol.rst Outdated Show resolved Hide resolved
@JordonPhillips JordonPhillips merged commit 75928a7 into smithy-lang:main Jun 17, 2021
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.

Clarification on how to serialize NaN, Infinity, and NegInfinity for AWS protocols
3 participants