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

Adopt a more flexible way of resolving $ref references #82

Open
jprobinson opened this issue Apr 9, 2018 · 2 comments
Open

Adopt a more flexible way of resolving $ref references #82

jprobinson opened this issue Apr 9, 2018 · 2 comments

Comments

@jprobinson
Copy link
Contributor

We still have the kubernetes.json fixture commented out from tests due to a (valid) JSON Schema $ref to point to a string type:

     "$ref": {
      "type": "string"
     },

We should be able to detect this and simply resolve it as a type: string.

Hopefully this is the only thing preventing us from using the k8s spec as a fixture :)

@lestrrat
Copy link
Contributor

IIRC this was not necessarily because of the "$ref" itself, but it was rather in the way that the openapi2proto code expects only objects. I think something can be worked out, but I think it's more of a matter of coming up with a minimal test case first.

@curiousleo
Copy link

I'm looking into this in the context of #128.

https://tools.ietf.org/html/draft-pbryan-zyp-json-ref-03 states in section 3:

    A JSON Reference is a JSON object, which contains a member named
   "$ref", which has a JSON string value.  Example:

   { "$ref": "http://example.com/example.json#/foo/bar" }

   If a JSON value does not have these characteristics, then it SHOULD
   NOT be interpreted as a JSON Reference.

   The "$ref" string value contains a URI [RFC3986], which identifies
   the location of the JSON value being referenced.  It is an error
   condition if the string value does not conform to URI syntax rules.
   Any members other than "$ref" in a JSON Reference object SHALL be
   ignored.

That seems pretty clear - $ref should contain a URI. Under which circumstances would

     "$ref": {
      "type": "string"
     }

be valid according to the OpenAPI spec?

curiousleo added a commit to curiousleo/openapi2proto that referenced this issue Sep 16, 2020
Fixes nytimes#128 and nytimes#82.

Changes:
- Ignore $ref declarations that are not strings (dubious)
- Allow builtins as RPC return types
- Update Kubernetes proto fixture (dubious)
sanposhiho pushed a commit to sanposhiho/openapi2proto that referenced this issue May 21, 2023
Fixes nytimes#128 and nytimes#82.

Changes:
- Ignore $ref declarations that are not strings (dubious)
- Allow builtins as RPC return types
- Update Kubernetes proto fixture (dubious)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants