{"id":15478525,"url":"https://github.com/codekie/openapi-examples-validator","last_synced_at":"2025-05-05T04:03:47.659Z","repository":{"id":37431081,"uuid":"78840041","full_name":"codekie/openapi-examples-validator","owner":"codekie","description":"Validates embedded examples in OpenAPI-files","archived":false,"fork":false,"pushed_at":"2025-04-21T18:56:45.000Z","size":3030,"stargazers_count":58,"open_issues_count":10,"forks_count":14,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-05-05T04:03:32.053Z","etag":null,"topics":["docker","javascript","openapi","openapi3","validation"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/codekie.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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,"zenodo":null}},"created_at":"2017-01-13T10:34:47.000Z","updated_at":"2025-04-21T18:56:48.000Z","dependencies_parsed_at":"2023-02-14T09:46:49.311Z","dependency_job_id":"ed3328af-7195-466d-9337-f12ca70567df","html_url":"https://github.com/codekie/openapi-examples-validator","commit_stats":{"total_commits":243,"total_committers":9,"mean_commits":27.0,"dds":"0.16049382716049387","last_synced_commit":"2a4758dcf624793dcdd197f00fc1f313792dfaf1"},"previous_names":["codekie/swagger-examples-validator"],"tags_count":50,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekie%2Fopenapi-examples-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekie%2Fopenapi-examples-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekie%2Fopenapi-examples-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codekie%2Fopenapi-examples-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codekie","download_url":"https://codeload.github.com/codekie/openapi-examples-validator/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252436291,"owners_count":21747470,"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":["docker","javascript","openapi","openapi3","validation"],"created_at":"2024-10-02T04:05:26.389Z","updated_at":"2025-05-05T04:03:47.636Z","avatar_url":"https://github.com/codekie.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"openapi-examples-validator\n==========================\n\nValidates embedded JSON-examples in OpenAPI-specs (v2 and v3 are supported)\n\n[![npm version](https://badge.fury.io/js/openapi-examples-validator.svg)](https://badge.fury.io/js/openapi-examples-validator)\n[![Standard Version](https://img.shields.io/badge/release-standard%20version-brightgreen.svg)](https://github.com/conventional-changelog/standard-version)\n[![Run tests](https://github.com/codekie/openapi-examples-validator/actions/workflows/test-and-deploy-docker.yml/badge.svg?query=branch%3Amain)](https://github.com/codekie/openapi-examples-validator/actions/workflows/test-and-deploy-docker.yml?query=branch%3Amain)\n[![Coverage Status](https://coveralls.io/repos/github/codekie/openapi-examples-validator/badge.svg?branch=main)](https://coveralls.io/github/codekie/openapi-examples-validator?branch=main)\n[![Mutation testing badge](https://badge.stryker-mutator.io/github.com/codekie/openapi-examples-validator/main)](https://stryker-mutator.github.io)\n[![Maintainability](https://api.codeclimate.com/v1/badges/5094f6ac7754e5a18b1b/maintainability)](https://codeclimate.com/github/codekie/openapi-examples-validator/maintainability)\n[![Known Vulnerabilities](https://snyk.io/test/github/codekie/openapi-examples-validator/badge.svg)](https://snyk.io/test/github/codekie/openapi-examples-validator)\n[![Docker Hub](https://img.shields.io/badge/docker-ready-blue.svg)](https://hub.docker.com/r/codekie/openapi-examples-validator)\n\nPrerequisites\n------------\n\n- [Node.js](https://nodejs.org/) \u003e=18.\n\nInstall\n-------\n\nInstall using [npm](https://docs.npmjs.com/getting-started/what-is-npm):\n\n    npm install -g openapi-examples-validator\n\nUsage\n-----\n\n```\nopenapi-examples-validator [options] \u003cfilepath\u003e\n\nValidate embedded examples in OpenAPI-specs (JSON and YAML supported).\n  To validate external examples, use the `-s` and `-e` option.\n  To pass a mapping-file, to validate multiple external examples, use the `-m` option.\n\nOptions:\n  -V, --version                              output the version number\n  -s, --schema-jsonpath \u003cschema-jsonpath\u003e    Path to OpenAPI-schema, to validate the example file against\n  -e, --example-filepath \u003cexample-filepath\u003e  file path to example file, to be validated\n  -m, --mapping-filepath \u003cmapping-filepath\u003e  file path to map, containing schema-paths as key and the file-path(s) to\n                                             examples as value. If wildcards are used, the parameter has to be put in\n                                             quotes.\n  -c, --cwd-to-mapping-file                  changes to the directory of the mapping-file, before resolving the\n                                             example's paths. Use this option, if your mapping-files use relative paths\n                                             for the examples\n  -n, --no-additional-properties             don't allow properties that are not described in the schema\n  -r, --all-properties-required              make all the properties in the schema required\n  -o, --ignore-formats \u003cignored-formats...\u003e  Datatype formats to ignore (to prevent \"unknown format\" errors.)\n  -h, --help                                 output usage information\n````\n\nThe validator will search the OpenAPI-spec for response-examples and validate them against its schema.\n\nIf an external example has to be verified, the `-s` and `-e` option has to be used.\n\nFor example:\n\n```\n$ openapi-examples-validator -s $.paths./.get.responses.200.schema -e example.json openapi-spec.json\n```\n\nTo validate multiple external examples, pass a mapping file with a similar structure along with the `-m` option:\n\n```json\n{\n  \"$.paths./.get.responses.200.schema\": [\n    \"test/data/external-examples-valid-example1.json\",\n    \"test/data/external-examples-valid-example2.json\",\n    \"test/data/external-examples-invalid-type.json\"\n  ],\n  \"$.paths./.get.responses.300.schema\": \"test/data/external-examples-invalid-missing-link.json\",\n  \"$.paths./.post.parameters[?(@.in===\"body\")].schema\": \"test/data/v2/post-request/*.json\"\n}\n```\nIt is possible to use wildcards in the command line to select multiple mapping files, and it is possible to use wildcards inside the mapping file to select multiple examples.\n\nErrors will be written to `stderr`.\n\nSample output of validation errors:\n\n```json\n[\n    {\n        \"keyword\": \"type\",\n        \"instancePath\": \"/versions/0/id\",\n        \"schemaPath\": \"#/properties/versions/items/properties/id/type\",\n        \"params\": {\n            \"type\": \"string\"\n        },\n        \"message\": \"must be string\",\n        \"examplePath\": \"/~1/get/responses/200/examples/application~1json\"\n    }\n]\n```\n\nDocker\n------\n\nExample usage:\n\n```shell\n$ docker run --rm -i \\\n    --user=$(id -u) \\\n    -v ${PWD}:/data \\\n    codekie/openapi-examples-validator:latest \\\n    /data/test/data/v3/simple-api-with-examples-with-refs-invalid.yml\n```\n\nCaveat\n------\n\n- The formats `int32`, `float` and `double` are supported for the type `number`. The format `int64` is only available\n  for the type `string`, though (due to the precision-limitations of Javascript).\n- The options `--no-additional-properties` and `--all-properties-required` are not compatible with [sub-schemas combiner keyword](https://json-schema.org/understanding-json-schema/reference/combining.html). A warning will be logged if one model is skipped because it contains a combiner keyword.\n\nTest\n----\n\nTo run the tests, execute\n\n    npm test\n\nor to check the coverage\n\n    npm run coverage\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodekie%2Fopenapi-examples-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodekie%2Fopenapi-examples-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodekie%2Fopenapi-examples-validator/lists"}