apidoc-to-openapi-converter
v0.1.0
Published
Convert apiDoc api_data.js output to an OpenAPI 3 JSON spec.
Maintainers
Readme
apidoc-to-openapi-converter
This project provides a Node.js script to convert API documentation written in apiDoc format into the OpenAPI specification. Use this tool to migrate existing apiDoc documentation to the widely adopted OpenAPI standard and integrate with tools like Swagger UI or OpenAPI code generators.
Features
- Parses apiDoc-generated documentation and maps endpoints, parameters and responses to an OpenAPI 3 specification.
- Outputs a single JSON file containing your API definition.
Prerequisites
- Node.js installed on your system.
- The apiDoc tool installed to generate the intermediate apiDoc output.
Usage
- Generate your apiDoc documentation as JSON by running apiDoc on your source files:
This produces a file calledapidoc -i <source-code-folder> -o apidoc_outputapi_data.jsinside theapidoc_outputdirectory containing the extracted API information. - Run the converter on the
api_data.jsfile and redirect the result to an OpenAPI file:node converter.js apidoc_output/api_data.js > openapi.json - Open
openapi.jsonwith an OpenAPI-compatible tool (e.g. Swagger UI) to view or further process the specification.
Install (npm)
Global install (recommended for CLI):
npm i -g apidoc-to-openapi-converter
apidoc-to-openapi apidoc_output/api_data.js > openapi.jsonWithout global install:
npx -p apidoc-to-openapi-converter apidoc-to-openapi apidoc_output/api_data.js > openapi.jsonProgrammatic usage
const { convertApiDocToOpenApi } = require('apidoc-to-openapi-converter');
const openapiJson = convertApiDocToOpenApi({ apiDataPath: 'apidoc_output/api_data.js' });Contributing
Contributions are welcome! If you find a bug or have ideas for improvements, please open an issue or submit a pull request.
License
This project currently does not include a license file. Feel free to suggest an appropriate license via a pull request.
