{"id":15382674,"url":"https://github.com/derberg/convert-swagger-to-openapi-playground","last_synced_at":"2025-08-03T10:30:44.472Z","repository":{"id":90359285,"uuid":"288430830","full_name":"derberg/convert-swagger-to-openapi-playground","owner":"derberg","description":"Some instructions and sample how to convert Swagger 2.0 files to OpenAPI 3.0","archived":false,"fork":false,"pushed_at":"2020-08-18T13:01:16.000Z","size":14,"stargazers_count":3,"open_issues_count":0,"forks_count":2,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-30T23:04:40.916Z","etag":null,"topics":["convert","openapi","openapi3","swagger","swagger2"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derberg.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-18T10:58:26.000Z","updated_at":"2024-06-05T04:33:40.000Z","dependencies_parsed_at":null,"dependency_job_id":"bce78bba-d55f-4646-aae2-b22d4075b6bb","html_url":"https://github.com/derberg/convert-swagger-to-openapi-playground","commit_stats":{"total_commits":2,"total_committers":1,"mean_commits":2.0,"dds":0.0,"last_synced_commit":"c6ffa850b7440fde093c002f82d9dd442aa6d0e2"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derberg%2Fconvert-swagger-to-openapi-playground","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derberg%2Fconvert-swagger-to-openapi-playground/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derberg%2Fconvert-swagger-to-openapi-playground/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derberg%2Fconvert-swagger-to-openapi-playground/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derberg","download_url":"https://codeload.github.com/derberg/convert-swagger-to-openapi-playground/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228535815,"owners_count":17933254,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["convert","openapi","openapi3","swagger","swagger2"],"created_at":"2024-10-01T14:33:40.039Z","updated_at":"2024-12-06T23:08:56.614Z","avatar_url":"https://github.com/derberg.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Convert Swagger to OpenAPI Playground\n\nStaying with Swagger 2.0 is like staying with ... still working on a good comparison. Anyway, you should migrate to OpenAPI, and my goal here is not to convince you why. I assume you already made this smart decision, and I just want to make it easier for you.\n\nI did not perform any more in-depth investigation of available tools. There are [tools](https://github.com/Mermade/oas-kit) provided by Mermade Software. To be more specific, by [Mike Ralphson](https://twitter.com/PermittedSoc) that is a member of [Technical Steering Committee](https://github.com/OAI/OpenAPI-Specification/blob/master/MAINTAINERS.md). For me, this is a good reason not to research different tools.\n\n- [Convert in a Browser](#convert-in-a-browser)\n- [Convert in a Terminal](#convert-in-a-terminal)\n    - [NPM](#npm)\n    - [NPX](#npx)\n    - [Docker](#docker)\n- [Convert Multiple Files](#convert-multiple-files)\n\n## Convert in a Browser\n\nConversion in a browser is addressed by [Kin Lane](https://twitter.com/kinlane) aka API Evangelist in [this thread and the video](https://twitter.com/apievangelist/status/1295502093625643008) so watch it and go to https://mermade.org.uk/openapi-converter\n\n## Convert in a Terminal\n\nUse [swagger2openapi](https://github.com/Mermade/oas-kit/blob/master/packages/swagger2openapi/README.md) and have fun:\n\n### NPM\n\n1. Install the tool `npm install -g swagger2openapi`\n1. Run conversion `swagger2openapi --yaml --outfile openapi.yaml https://petstore.swagger.io/v2/swagger.json`\n\nAnd that is it. Check your new `openapi.yaml` file.\n\n### NPX\n\n[NPX](https://www.npmjs.com/package/npx) is useful in CI/CD where you do not want to install `swagger2openapi` globally.\n\n`npx -p swagger2openapi swagger2openapi --yaml --outfile openapi.yaml https://petstore.swagger.io/v2/swagger.json`\n\n### Docker\n\nNPM and NPX is not your thingy? use the Docker image provided by Mike.\n\n```bash\n#this part \"-v ${PWD}:/usr/src/app\" mounts the directory where you started \"docker run\" inside the container where CLI is triggered, this way generated \"openapi.yaml\" gets into your local drive\ndocker run --rm -v ${PWD}:/usr/src/app mermade/swagger2openapi swagger2openapi --yaml --outfile openapi.yaml https://petstore.swagger.io/v2/swagger.json\n```\n\n## Convert Multiple Files\n\nYou most probably have many services, and you need to convert many Swagger files, and you do not want to do it one by one but all at once with a script. You can use Bash and write some script that runs the CLI, but writing Bash scripts is like ... yeah, one day I'll find a good comparison.\n\nJust use `swagger2openapi` as a library. In `convertmultiple` directory, you can find a [sample code](convertmultiple/index.js) that you can easily edit for your needs. Its code has proper comments that will help you understand what parts you might change in case you have different directory structure or filenames than the ones used in the sample\n\nTo play with the example, perform the following steps:\n1. `git clone https://github.com/derberg/convert-swagger-to-openapi-playground.git`\n1. `cd convert-swagger-to-openapi-playground/convertmultiple`\n1. `npm install`\n1. `npm start`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderberg%2Fconvert-swagger-to-openapi-playground","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderberg%2Fconvert-swagger-to-openapi-playground","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderberg%2Fconvert-swagger-to-openapi-playground/lists"}