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

Relative paths not supported #87

Open
jsdevel opened this issue Nov 30, 2015 · 5 comments
Open

Relative paths not supported #87

jsdevel opened this issue Nov 30, 2015 · 5 comments

Comments

@jsdevel
Copy link

jsdevel commented Nov 30, 2015

I kept getting this with something like "$ref": "Address.json" in one of my definitions. The definition file had a sibling Address.json file in the same directory.

Here's the error:
callstack-exceeded-error

Not really sure how it could work though as swaggerize-express is expecting definitions to be an object:

must-be-an-object

See the docs for reference object

swagger-relative

@tlivings
Copy link
Contributor

If you want to use external references like this, you can use extrefs module to resolve them in advance.

That being said, we need to build support for this in directly.

@krazylearner
Copy link

HI
i am facing same problem . The middleware is not working with documents which contain '$ref' to other json documents which are relative files.
thanks

@tlivings
Copy link
Contributor

We're working on making references resolve automatically. But the way around this is to resolve references before hand:

import Express from 'express';
import Swaggerize from 'swaggerize-express';
import Resolver from 'extrefs';

const app = Express();

Resolver(api).resolve((error, schemas) => {
    app.use(Swaggerize({ api, handlers, schemas}));

    //etc
});

@jsdevel
Copy link
Author

jsdevel commented Jul 25, 2016

I'm now using express-openapi, and find it's usage of jsonpath to be a lot more stable. Perhaps switching to jsonpath would make the transition smoother and resolve a lot of other validation bugs?

@tlivings
Copy link
Contributor

We're working on conversion to use swagger-parser but integration with an asynchronous resolver requires some work to maintain consistency with the current API.

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