-
Notifications
You must be signed in to change notification settings - Fork 57
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
Handling $ref-s to external files (canonical dereferencing) #33
Comments
This should already be possible using the schemas option passed to builder. |
@tlivings: yes, that seems to be what I'm after - and a nicer solution at that! Only that I cannot get it to work. It's quite possible that I'm missing something, but it looks to me like It seems that as long as any subSchemas are provided, Here's the key part (lib/index.js, lines 52-54): enjoi(require('./schema/swagger-spec/schemas/v2.0/schema.json'), schemas).validate(options.api, function (error) {
assert.ifError(error);
}); As long as
I think that's it for this issue, but could you confirm that this looks like a material for another one at |
Yeah that definitely doesn't sound right. Please open an issue and let's keep this one open as well until resolved. |
So there are two tests for this: https://github.com/tlivings/enjoi/blob/master/test/test-enjoi.js#L64 and https://github.com/tlivings/enjoi/blob/master/test/test-enjoi.js#L87 Which indicate this shouldn't be an issue in In But you are right! There is a bug. Basically the sub schemas should contain the swagger schema for that particular validation call under a key |
Should it really be needed for provided Getting back to the issue at hand - But, actually, the more I read, the more it seems like a bad idea. Right now Swagger UI still needs some things in the spec to be referenced, i.e. not accepting inline schema definitions ( swagger-api/swagger-js#189 ). It's not handling multi-level references either (my observation: So maybe we should skip such pre-processing of api-docs, at least for now. Even then I'm getting doubtful such functionality falls within the scope of this project. |
This should now be resolved after the last couple of published to |
@tlivings You might want to cross-check against recent updates to specs/examples/swagger-js: This is en route for swagger-js: Already updated in the Swagger spec: |
It's sort of strange that they are using file names in $ref. That places requirements in validators to load files during validation. |
Right, but if you try to scale out microservices, you have to. So far, they've only supported I'm also working on adding a command-line option to https://github.com/BigstickCarpet/swagger-parser ...but you can use that to do all of the resolution stuff (it already supports relative file resolution quite nicely). |
Actually $ref should only be an id followed by a path. Uris are simply used as ids typically. Some validators might pre-resolve refs for validation afterwards, but it depends on the validator. Placing an assumption that the validator will read a file or fetch a url is non standard imo. |
I should probably open an issue on swagger to discuss this. |
Reuse is already pretty clearly defined at: Also, Swagger specifies JSON Reference, which is very well defined (used as the supporting material for the addition). Swagger-Parser, for instance, already supports all of this. There's an open ticket (at request of @webron) to update this in the Swagger spec: |
👍 |
Related: #20 .
This is feature request for being able to split swagger spec into several (or many...) files.
Right now we're able to reference only parameters available in the main (same) swagger spec file:
What's lacking is possibility to reference external files, per http://json-schema.org/latest/json-schema-core.html#anchor30 :
This would /greatly/ help to prevent main spec file from getting huge/hard to navigate.
Am I the only one who would want this? I already have some code laying around doing this, but outside of
swaggerize-builder
- basically just preprocessing .json file before it's passed on to it. I'm more than willing to try to package it into PR (probably extending currentrefresolver
function in validator), but was also thinking about using some ready-made parsing library (couldn't find a good one though). Any ideas will be welcome.The text was updated successfully, but these errors were encountered: