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

Add support for OpenAPI v3 #4

Open
wants to merge 1 commit into
base: develop
from

Conversation

Projects
None yet
3 participants
@JonathanMontane
Owner

JonathanMontane commented Aug 27, 2017

Not Ready For Review

This PR will add an OpenAPI v3 Parser to API-Flow.

@philsturgeon It's being worked on!

@philsturgeon

This comment has been minimized.

philsturgeon commented Aug 28, 2017

Awesome! Can I help at all? I'll of course test things when it's considered readyish.

@JonathanMontane

This comment has been minimized.

Owner

JonathanMontane commented Aug 28, 2017

@philsturgeon If you have shareable OpenAPI v3 files lying around, I'd love to have them as test-case for the e2e testing. Otherwise, if you're up for it, I'm looking to massively upgrade dependencies while trying not to break too many things.

As for your install issue, I believe the issue you're having with the installation stems from having used the npm package. It's outdated iirc, and I don't have the rights to publish on it anymore.

Here's the updated install step:

git clone git@github.com:JonathanMontane/API-Flow.git
cd API-Flow
nvm use
yarn install

then you can make your runners. for instance, creating the node runner would be done like so:

make runners TARGET="node"
# you can create multiple targets in the same command
# make runners TARGET="node web webworker"

once you've created the node lib, you can use it like this:

const ApiFlow = require('./dist/node/api-flow.js').default; // the .default is due to es6 modules structure.

const options = {
    source: {
        format: 'swagger',
        version: 'v2.0'
    },
    target: {
        format: 'raml',
        version: 'v1.0'
    }
}

const promise = ApiFlow.transform({
  options,
  // this also works with file uri like: file:///some/path, or simply /some/path
  // check out https://apis.guru/browse-apis/ -- it's amazing
  uri: 'https://api.apis.guru/v2/specs/6-dot-authentiqio.appspot.com/6/swagger.json'
})

promise.then((data) => {
  console.log(data)
})

I just did all the steps, and it worked, so it should work for you too.

Note For some reason I had an Error: define cannot be used indirect bug when I did an npm install instead of a yarn install (with make runners generating warnings about /~/lib/ajv or something), so I'd recommend using yarn, although I'm not too sure how that got resolved.

@MikeRalphson

This comment has been minimized.

MikeRalphson commented Sep 25, 2017

@JonathanMontane thanks for the mention of APIs.guru (I'm the current maintainer). You may not know that there is a static branch full of OpenAPI v3 conversions at https://github.com/APIs-guru/openapi-directory/tree/openapi3.0.0/APIs

Eventually I'd like to replace use of api-spec-converter in the APIs.guru scripts with API-Flow.

Let me see if I can run the test-suite successfully (edit: unit tests running ok with a slight tweak to test.sh - still looking at e2e tests), then I can see about helping with dependency updates and possibly contributing to your OpenApiV3 work. I've currently got a loader and parser hacked from the Swagger2 equivalents, which is enough to validate an input V3 definition and produce reasonable looking output from the internal model, but I've only dealt with minor structural changes so far (scheme+host -> servers.url and definitions -> components.schemas).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment