{"id":15704033,"url":"https://github.com/nikolaydubina/openapi-inline-examples","last_synced_at":"2025-05-12T14:28:01.304Z","repository":{"id":57578452,"uuid":"354187356","full_name":"nikolaydubina/openapi-inline-examples","owner":"nikolaydubina","description":"🌏 Inline OpenAPI JSON examples from filenames ","archived":false,"fork":false,"pushed_at":"2024-08-22T09:10:15.000Z","size":178,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-12T14:27:40.007Z","etag":null,"topics":["documentation","openapi"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nikolaydubina.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":"CITATION.cff","codeowners":".github/CODEOWNERS","security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2021-04-03T03:11:13.000Z","updated_at":"2024-08-22T09:10:19.000Z","dependencies_parsed_at":"2024-06-20T12:01:16.618Z","dependency_job_id":"0b95c85a-a9a9-43b2-ae40-a54fcf9401de","html_url":"https://github.com/nikolaydubina/openapi-inline-examples","commit_stats":{"total_commits":23,"total_committers":1,"mean_commits":23.0,"dds":0.0,"last_synced_commit":"b8113584187c99b5f90516a664c24fa38cb28f99"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Fopenapi-inline-examples","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Fopenapi-inline-examples/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Fopenapi-inline-examples/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nikolaydubina%2Fopenapi-inline-examples/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nikolaydubina","download_url":"https://codeload.github.com/nikolaydubina/openapi-inline-examples/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":253754495,"owners_count":21958872,"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":["documentation","openapi"],"created_at":"2024-10-03T20:09:58.415Z","updated_at":"2025-05-12T14:28:01.268Z","avatar_url":"https://github.com/nikolaydubina.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![codecov](https://codecov.io/gh/nikolaydubina/openapi-inline-examples/branch/main/graph/badge.svg?token=J97ET3LIQA)](https://codecov.io/gh/nikolaydubina/openapi-inline-examples)\n[![OpenSSF Scorecard](https://api.securityscorecards.dev/projects/github.com/nikolaydubina/openapi-inline-examples/badge)](https://securityscorecards.dev/viewer/?uri=github.com/nikolaydubina/openapi-inline-examples)\n\n\u003e How do I add JSON examples to `openapi.yaml` from `.json` files?\n\nAdd to your `openapi.yaml` annotation `#source \u003cfilepath\u003e` like\n\n```yaml\nopenapi: 3.0.0\ninfo:\n  version: 1.0.0\n  title: Swagger Marvelstore\n\npaths:\n  /users:\n    get:\n      responses:\n        '200':\n          description: A user object.\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  id:\n                    type: integer\n                    format: int64\n                    example: 4\n                  name:\n                    type: string\n                    example: Jessica Smith\n              examples:\n                basic:\n                  value: #source testdata/user-basic.json\n        '400':\n          description: The specified user ID is invalid (not a number).\n          content:\n            application/json:\n              examples:\n                basic 400:\n                  value: #source testdata/error-400.json\n```\n\n.. then run \n\n```\n$ go install github.com/nikolaydubina/openapi-inline-examples@latest\n$ cat openapi.yaml | openapi-inline-examples \u003e openapi.new.yaml\n```\n\n.. which will produce\n\n```yaml\nopenapi: 3.0.0\ninfo:\n  version: 1.0.0\n  title: Swagger Marvelstore\n\npaths:\n  /users:\n    get:\n      responses:\n        '200':\n          description: A user object.\n          content:\n            application/json:\n              schema:\n                type: object\n                properties:\n                  id:\n                    type: integer\n                    format: int64\n                    example: 4\n                  name:\n                    type: string\n                    example: Jessica Smith\n              examples:\n                basic:\n                  value: {\"id\":42,\"name\":\"Nick Fury\"} #source testdata/user-basic.json\n        '400':\n          description: The specified user ID is invalid (not a number).\n          content:\n            application/json:\n              examples:\n                basic 400:\n                  value: {\"errors\":[{\"message\":\"resource not found\",\"status\":400,\"translation_data\":\"some translation identifier\"}]} #source testdata/error-400.json\n```\n\n.. which renders nicely as multiple examples that you can select\n\n![example-preview](docs/example.png)\n\nWhy would anyone need this?\n\n- Keep your OpenAPI up to date with values you use in tests\n- Can run multiple times\n- UNIX filter\n- Does not corrupt anything if fails at any stage\n- 100% test coverage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolaydubina%2Fopenapi-inline-examples","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnikolaydubina%2Fopenapi-inline-examples","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnikolaydubina%2Fopenapi-inline-examples/lists"}