How to split Swagger (OpenAPI) spec into small files ?

  1. Write details of each endpoints in a separate yaml files.
  2. Write each models in separate yaml files so that we can reuse it.
  3. Combine all the yaml files using `swagger-cli`
  4. Serve the swagger doc in html format using an express server

Write details of each endpoints in a separate yaml files.

Write each models in separate yaml files so that we can reuse it.

Following image refers the entry file (index.yaml)

Now combine the yaml files and generate single json file

# swagger-cli bundle swagger/index.yaml --outfile swagger/index.jsonyarn doc:generate

Serve the swagger doc in html format using an express server

Open http://localhost:3000/api/docs/ in browser then you could see the API documentations as below

--

--

--

Providing simple solutions for complex problems.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Updates on Fleta Connect (August 20th 2021)

Develop on Ontology

UpBots Weekly Wrap Up: February 18, 2022

Taking the data engineer out of ETL

Sysmon v10.42 individual events

Can Rasa’s Action Server Do Asynchronous Calls?

Use This Vehicle Detector API To Get Motorbikes Data

Grouping Anagrams

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Prince Francis

Prince Francis

Providing simple solutions for complex problems.

More from Medium

Python short-trick to load any local directory as python module in script

Mix Rhythmical Meters Of Ziket:

CAPA Implementation that Endures

How to write Python scripts that read arguments from the Command line