question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

OpenAPI incompatible with I-JSON

See original GitHub issue

https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.1.md#dataTypes

Apparently long maps (through JSON Schema) into JSON Number.

This is in conflict with I-JSON: https://tools.ietf.org/html/rfc7493

IMO, I-JSON is right. Promising 64 bits of precision when only 53 bit are readily available leads to unnecessary problems.

Suggested solution:

  • Keep long but add “deprecated”
  • Add int53 mapped into number
  • Add int64 mapped into string

Related: https://cyberphone.github.io/doc/security/draft-rundgren-json-canonicalization-scheme.html#json.bignumbers

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:19 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
darrelmillercommented, Mar 31, 2018

I think that there seem to be several competing visions here as to what JSON Schema and OpenAPI should be

Perhaps there are different visions of what JSON Schema and OpenAPI are trying to do, but it seems to me that the vision of the OpenAPI TSC is aligned with that of JSON Schema working group.

Let me try and use an analogy to see if we can agree on the different perspectives. Consider two different human languages, let’s say French and English. It seems to me, that what is being asked for in this thread is for OAS to define precise rules for describing how French words can be translated to English words. As nice as that idea sounds, there are lots of edge cases where it just wouldn’t work.

The way I see OpenAPI is that it is attempting to be an Esperanto for HTTP APIs. When people in France consume OpenAPI, then need to understand what is the highest fidelity way of translating Esperanto to French. When English people consume OpenAPI they translate in a way that makes the most sense from Esperanto.

It is not possible for the OpenAPI specification to accurately describe how to translate its typing concepts into every possible implementation language. It is the responsibility of the implementations to do the thing that makes the most sense in their native language. The hope is that the terms integer, boolean, string and number are universal enough that implementations can translate that concept into something native. Every time somebody tacks on a format there is a possibility that some platform may have to jump through hoops to make that happen.

I’m don’t want to even try to answer the question what does type: integer and format: int64 map to. It sort of depends if it is a URL parameter, a part of JSON payload, a HTML form, or a chunk of some binary blob. What I am relying on is that two tools on two different platforms will correctly translate the wire value to an internal native value that is consistent with the OpenAPI description.

The funny thing about interoperability that we have learned over the past 20 years is the more constrained you try and make the interface definition in order to avoid interoperability problems, the more interoperability problems you end up having in the real world. WSDL and XSD went to enormous lengths to be precise about interfaces and wire formats and datatypes and was significantly less effective at interoperability than far more loose alternatives.

0reactions
cyberphonecommented, Sep 18, 2022

We can close the thread now. You may have reasons revisiting it the day you begin supporting Decimal (monetary data) and BigNum which are distinct datatypes. Format-wise they can surely traverse through JSON Number but the value/gain seems limited and it will likely be incompatible with JavaScript which is about to be enriched with BigNum. I would consider doing a short research effort regarding the current use of Decimal/BigNum in conjunction with JSON. Microsoft uses a JSON Object in .NET for representing BigInteger so apparently interoperability isn’t that great for us poor JSON users 😞

OpenAPI obviously has a mission to fill here 😁

Read more comments on GitHub >

github_iconTop Results From Across the Web

Supported JSON Schema Keywords - Swagger
Supported JSON Schema Keywords. OpenAPI 3.0 uses an extended subset of JSON Schema Specification Wright Draft 00 (aka Draft 5) to describe the...
Read more >
How do I incorporate JSON schema into my OpenAPI file?
In OpenAPI 3.1, you can reference your JSON Schemas directly: ... removing unsupported keywords: $schema , patternProperties , and others; ...
Read more >
OpenAPI and JSON Schema: When to Use Which
OpenAPI v3.0 took us to 90% compatibility with JSON Schema Draft 5. In short, as of this writing, developers have never been able...
Read more >
py-openapi-schema-to-json-schema 0.0.3 - PyPI
Convert OpenAPI Schemas to JSON Schemas. ... and the enablement of unsupported JSON Schema features using OpenAPI extension fields ( x-patternProperties ...
Read more >
quart_openapi.swagger — Quart-OpenApi 1.7.2 documentation
"""swagger.py Provides the View class for generating the openapi.json file on ... ValueError('Unsupported type converter: %s' % converter) params[variable] ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found