Comments (10)
OASGraph currently does not support external references. I will file an issue for this.
Try copying and pasting the components into your OAS and see if you have any other issues.
from openapi-to-graphql.
@Alan-Cha, thanks for your quick response. Did you mean copying the path into your example at https://github.com/strongloop/oasgraph/blob/master/docs/tutorials/watson.md. After that, how do I run it?
from openapi-to-graphql.
This could be either pretty easy or a bit involved depending on what your OAS looks like.
You will probably see the following line somewhere in your OAS:
"$ref": "http://redfish.dmtf.org/schemas/v1/ServiceRoot.v1_4_0.yaml#/components/schemas/ServiceRoot"
To reiterate, the problem is that OASGraph currently does not support external references.
I followed the link and discovered that the document is in YAML so the first thing you will need to do is convert it to JSON.
Next, you should check to see how many external references are present in your OAS.
If this is the only external reference, then all you need to do is replace line above with the ServiceRoot
schema.
If there are multiple external references, then you should consider pulling in the full components object and changing all the references to local references.
To go into more detail, first check if you don't already have a preexisting components object in your OAS. If so, great! You can just copy the full components object into your OAS. If not, you will need to make sure make sure you do not have any collisions. Then, you will need to change all your external references to local references, which if they have the same form as above, should look like the following:
"$ref": "#/components/schemas/ServiceRoot"
from openapi-to-graphql.
@Alan-Cha, thanks for the detailed explanation. I saw a few external links however there is no components object inside OAS yaml file. If I copy all components object, do I need to follow each component link to copy each of them? thanks.
from openapi-to-graphql.
If all the links start with http://redfish.dmtf.org/schemas/v1/ServiceRoot.v1_4_0.yaml
, then that is probably the only components object you need.
If the external references point to different component objects, then you will need to combine them, which could mean you will encounter collisions.
In the end, you just need to satisfy the reference. Unfortunately, OASGraph currently does not support external references so you will have to either replace them with whatever they are referencing (for example, copying and pasting schema objects wherever the references are) or change them into local references (copying and pasting the entire components object at the root level and modifying the reference links).
from openapi-to-graphql.
I will close this issue because I have filed issue #65 but please feel free to ask more questions in this thread! 😄
from openapi-to-graphql.
@candysmurf You stated "there is no components object inside OAS yaml file". This could likely be the case because you are using an API specification written in OpenAPI Specification 2.0 (aka "Swagger"), which does not have a components
object. In that case, there should be a definitions
object, though, which contains descriptions of the data being sent to or returned from the API. Maybe within the referenced "ServiceRoot.v1_4_0.yaml" there is also a definitions
object from which you could copy the ServiceRoot
schema definition?!
from openapi-to-graphql.
I would like to follow up on this. We decided to use OASGraph and would like to see if you support yaml file and external references yet? @Alan-Cha & @ErikWittern
from openapi-to-graphql.
@candysmurf We added YAML support to the CLI tool (although we have yet to release a new version). We do not plan on adding external reference resolution right now, however. Although this would be a nice feature to have, we wonder if it lies outside the scope of OASGraph. This should be a library of its own.
from openapi-to-graphql.
from openapi-to-graphql.
Related Issues (20)
- Link checker report
- Remove the link from the About section for this repo
- How to pass different auth tokens for different specs?
- Link checker report
- Fields takes precedence over types
- Error when createGraphQLSchema github rest api docs HOT 1
- Link checker report
- Setting cookie in the response header is not working
- Queries with array parameters doesn't work HOT 1
- should have a content-type 'application/json' but has 'application/vnd.api+json'
- Any way to solve the N + 1 problem when I use Nest Object
- Correctly defined 204 will return Response does not have a Content-Type header
- openapi-to-graphql uses outdated package "graphql-upload" which uses vulnerable package "dicer"
- ERR_PACKAGE_PATH_NOT_EXPORTED upon fresh install HOT 2
- Enum case always in uppercase when converted in SDL HOT 1
- Generate Graphql schema without paths
- Support for OpenAPI Specification 3.1 HOT 1
- Failed to generate graphql types
- Support the conversion of date & datetime format to GraphQL type
- A swagger that has only POST api to graphql returns QueryPlaceholder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from openapi-to-graphql.