Typescript package to get an OpenApi-specification-compliant dereferenced object from an object or an json, yaml or yml file path string. For 3.1.x and 3.0.x OpenAPI versions.
npm install openapi-schema-retriever
or
yarn add openapi-schema-retriever
import schemaRetriever from 'openapi-schema-retriever'
const main = async () => {
/* schemaRetriever gets, checks and parses the openapi specification that can be an object or an file path string.
* If the specification input is a file path string, a second argument standing for the current working directory is mandatory.
* We recommend to use '__dirname' as second argument.
* The file must be either a json, a yaml or a yml file.
* schemaRetriever returns an dereferenced object in accordance with OpenAPI scpecification.
*/
const schema = await schemaRetriever('./openapi.yaml', __dirname)
console.log(schema) /* => {
openapi: '3.1.0'
...............
}
*/
}
main()
This package is licensed under the MIT License.
If you have any questions or issues, please contact the package maintainer at ekoulemaneng@gmail.com.