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

Resolve external $refs. #40

Open
tlivings opened this issue Jun 8, 2015 · 12 comments
Open

Resolve external $refs. #40

tlivings opened this issue Jun 8, 2015 · 12 comments
Labels
Milestone

Comments

@tlivings
Copy link
Contributor

tlivings commented Jun 8, 2015

No description provided.

@tlivings tlivings added the bug label Jun 8, 2015
@paul42
Copy link

paul42 commented Oct 8, 2015

if I'm having this issue, is the currently (only?) workaround to just declare parameters in routes?

@tlivings
Copy link
Contributor Author

tlivings commented Oct 8, 2015

You can use the extrefs module (https://www.npmjs.com/package/extrefs) to resolve everything beforehand and pass to the schemas option, but I will be integrating directly as well I think.

@paul42
Copy link

paul42 commented Oct 8, 2015

sorry, I misunderstood the root cause I'm having, and my issue is unrelated to this - it may not be in this module either

@tlivings
Copy link
Contributor Author

tlivings commented Oct 8, 2015

What are you seeing?

@paul42
Copy link

paul42 commented Oct 8, 2015

I'm still trying to iron out where the issue is occurring, but basically I see validation stop if I change from an in-route definition to a reference. I'm using swaggerize-restify & swaggerize-routes, as well as some more custom code

#1: the route before replacement https://gist.github.com/paul42/472fa78f2890e6766956
#2: make a GET to localhost:5002/v1/check/wrong?startDate='2015-10-01'
#3: result from that call: https://gist.github.com/paul42/ddcbe62b51976e6d2243
#4: the route after replacement https://gist.github.com/paul42/681770ce6cb7c3c6bbb7
#5: perform call from #2,
#6: result showing validator properly responding with error: https://gist.github.com/paul42/c7a8ad73922e8f180892

again, I'm still trying to find out what portion of code is causing this strange behavior, I don't know if it's any of the krakenjs/* stuff or in house code, but if you have any hints on what to investigate, I'd be extremely appreciative - thanks for taking the time to respond already

@jlee1201
Copy link

jlee1201 commented Mar 3, 2016

I have the same symptoms as @paul42 . using swaggerize-routes implicitly via swaggerize-hapi -- when using $ref, validation stops.

@jlee1201
Copy link

jlee1201 commented Mar 3, 2016

I figured out what was wrong. In my case, I had type:"object" along with the $ref and that was causing the enjoi module to attempt resolving the schema as an object. I removed the "type" field, and it started validating again. Hope this helps someone else

@wannabesrevenge
Copy link

@tlivings I'm looking to make this happen myself and submit a pull request. I plan on using swagger-parser as the main library, but it uses async callbacks. This would require an api change since right now its all synchronous code.

Do you have any aversions to an API change? If you do, do you have any thoughts on adding this functionality?

@tlivings
Copy link
Contributor Author

tlivings commented May 4, 2016

Yeah, I've considered adding this but the API change, at least for swaggerize-express gets pretty ugly. Due to the way express bootstraps, having an async swaggerize-routes would definitely change the dynamic and require something similar to what we do in kraken which keeps out requests until all bootstrapping is done.

I'm not totally opposed to it. It just presents some additional challenges for integration.

@jsdevel
Copy link

jsdevel commented May 4, 2016

Not trying to troll, but with express-openapi we actually flipped it. So instead of the library fetching the external schemas, we require the application to fetch them before initializing the app. See https://github.com/kogosoftwarellc/express-openapi#argsexternalschemas.

@tlivings
Copy link
Contributor Author

tlivings commented May 4, 2016

That's generally what I've recommended people to do before calling swaggerize.

@wannabesrevenge
Copy link

it seems like this is out of scope for the project given the design. I ended up doing the same as yall. this bug is kill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

6 participants