Closed floydpink closed 8 years ago
I think it's a node thing. Have you tried starting your processes from the folder that contains everything and then from there using relative paths to reach to each service and resolve it?
@mohsen1 - thank you, that helped. I had tried that before unsuccessfully and the reason why it failed then was another related thing. I was trying to use the latest of both json-refs
and yaml-js
and when I reverted those to what you have in this repo, Voila! - I got the relative path from root to work.
Here is the diff of the non-working newer dependencies getting reverted to the versions from this repo:
},
"license": "MIT",
"dependencies": {
- "json-refs": "^2.0.3",
- "yaml-js": "^0.1.3"
+ "json-refs": "^1.0.0",
+ "yaml-js": "^0.1.1"
}
}
Here is how the working set of specs that is getting run from the root of the package (no more process.chdir
):
_Service A_:
swagger: '2.0'
info:
title: service_A
description: service_A-description.
version: 1.0.0
host: service_A-host.org
schemes:
- https
basePath: /svcA
produces:
- application/json
consumes:
- application/json
paths:
$ref: ./specs/service_A/paths/index.yaml
definitions:
$ref: ./specs/definitions.yaml
_Service B_:
swagger: '2.0'
info:
title: service_B
description: service_B-description.
version: 1.0.0
host: service_B-host.org
schemes:
- https
basePath: /svcB
produces:
- application/json
consumes:
- application/json
paths:
$ref: ./specs/service_B/paths/index.yaml
definitions:
$ref: ./specs/definitions.yaml
I am running the resolver as part of a CI script to generate and save the combined serviceA.json
and serviceB.json
which then gets consumed by Swagger-UI (as well as a read-only version of Swagger-Editor).
Thank you for the blog, this repo and all the great work on Swagger UI (and other tools).
I am trying to use the method from this repo and the associated article to reuse the model definitions between two or three separate service definitions.
This is the folder structure I have:
Both
service_A/index.yaml
andservice_B/index.yaml
are similar to this:I had to change the working directory to be within
specs/service_A
usingprocess.chdir('specs/service_A');
, but the definitions that are a level above the working directory is not being expanded.Do you have any guidance on how I should structure the files to have reusability across two sets of services?