swaggerize-express icon indicating copy to clipboard operation
swaggerize-express copied to clipboard

Relative paths not supported

Open jsdevel opened this issue 10 years ago • 5 comments

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

jsdevel avatar Nov 30 '15 19:11 jsdevel

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.

tlivings avatar Nov 30 '15 22:11 tlivings

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

krazylearner avatar Jul 24 '16 14:07 krazylearner

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
});

tlivings avatar Jul 24 '16 15:07 tlivings

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?

jsdevel avatar Jul 25 '16 07:07 jsdevel

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.

tlivings avatar Jul 25 '16 13:07 tlivings