{"id":38964041,"url":"https://github.com/gcatanese/openapi-request-response-validation","last_synced_at":"2026-01-17T16:27:34.398Z","repository":{"id":103487773,"uuid":"584163624","full_name":"gcatanese/openapi-request-response-validation","owner":"gcatanese","description":"Validation of request/response according to OpenAPI specs","archived":false,"fork":false,"pushed_at":"2025-12-18T18:52:40.000Z","size":265,"stargazers_count":15,"open_issues_count":10,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-12-21T21:33:03.025Z","etag":null,"topics":["api","openapi","openapi3","openapi31","validation"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gcatanese.png","metadata":{"files":{"readme":"README.md","changelog":null,"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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-01-01T16:44:30.000Z","updated_at":"2025-08-29T12:16:18.000Z","dependencies_parsed_at":"2024-08-14T12:48:06.473Z","dependency_job_id":"fb0a4e4e-1997-491f-bc00-a57449cf608b","html_url":"https://github.com/gcatanese/openapi-request-response-validation","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/gcatanese/openapi-request-response-validation","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcatanese%2Fopenapi-request-response-validation","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcatanese%2Fopenapi-request-response-validation/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcatanese%2Fopenapi-request-response-validation/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcatanese%2Fopenapi-request-response-validation/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gcatanese","download_url":"https://codeload.github.com/gcatanese/openapi-request-response-validation/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gcatanese%2Fopenapi-request-response-validation/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28511864,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-17T13:38:16.342Z","status":"ssl_error","status_checked_at":"2026-01-17T13:37:44.060Z","response_time":85,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["api","openapi","openapi3","openapi31","validation"],"created_at":"2026-01-17T16:27:34.176Z","updated_at":"2026-01-17T16:27:34.318Z","avatar_url":"https://github.com/gcatanese.png","language":"Java","readme":"# OpenAPI validator\n\nThis tool allows the validation at runtime of the API requests responses according to the OpenAPI specs.  \n\nThere are several tools that can validate an OpenAPI specification, but there are no many options to ensure that the API contracts are honoured by the API we are developing.\n\nThis tool make sure that the API requests and responses are valid according to the OpenAPI specification of the API.\n\nMore on [Validating API requests and responses](https://beppecatanese.hashnode.dev/validating-api-requests-and-responses)\n\nThe `openapi-request-response-validator` is a SpringBoot (Java) application implementing a REST controller to allow Postman scripts (or other clients) to send the payload to be validated. The OpenAPI file can be supplied at startup.\n\n## How does it work?\n\nYou work with Postman to test the API endpoints, sending a request and verify the response. Thanks to Postman [Test Scripts](https://learning.postman.com/docs/writing-scripts/test-scripts/) it is possible to add custom scripts to access the  `request`, `response` and `headers` programmatically and send them to the OpenAPI Request-Response Validator.\nPostman tests (with assertions) can be defined to confirm the JSON payloads are valid according to the API specification.\n\n![OpenAPI Validator](doc/openapi-validator.png)\n\nThe outcome of the validation (together with the list of errors — if any) is returned to Postman (displayed in the Postman console) and logged by the application.\n\n\n## How to run\n\nSteps:\n* add the snippet below in the Collection Tests\n* provide the OpenAPI file\n* launch the `openapi-request-response-validation` tool ([Java app](#start-the-tool-java) or using [Docker](#start-the-tool-docker)) \n* run the Postman requests against your service or application \n\n### Collection Test snippet\n\nIn the **Collection Tests** add the snippet below. It will run after every request in the collection.  \n\nWhat does it do? After executing the request the Test Script will send `request`, `response` and `headers` to the validator.\n\n```\nopenapiRequestResponseValidation = {\n    validate: function(pm) {\n    \n        // build path without baseUrl\n        var baseUrl = pm.collectionVariables.get(\"baseUrl\");\n        baseUrl = baseUrl.replace('https://','');\n        baseUrl = baseUrl.replace(pm.request.url.getHost(),'');\n\n        var path = pm.request.url.getPath().replace(baseUrl,'');\n\n        console.log('Validation for ' + path);\n\n        const postRequest = {\n            url: 'http://localhost:8080/validate',\n            method: 'POST',\n            header: {'Content-Type': 'application/json'},\n            body: {\n            mode: 'raw',\n            raw: JSON.stringify({ \n                method: pm.request.method, \n                path: path,\n                headers: pm.request.headers,\n                requestAsJson: (pm.request.body != \"\") ? pm.request.body.raw : null,\n                responseAsJson: pm.response.text(),\n                statusCode: pm.response.code\n                })\n            }\n        };\n\n        pm.sendRequest(postRequest, (error, response) =\u003e {\n            if(error != undefined) {\n                pm.expect.fail('Unexpected error ' + error);\n            } else {\n                var data = response.json();\n\n                if(data.valid == false) {\n                    console.log(data.errors);\n                }\n\n                pm.test(\"OpenAPI validation\", () =\u003e {\n                    pm.expect(data.valid, \"Invalid request/response (check Console)\").to.equal(true);\n                });\n\n            }\n        });  \n    }\n\n};\n\nopenapiRequestResponseValidation.validate(pm);\n```\n\n### Provide the OpenAPI spec file\n\nCopy/rename your OpenAPI specs to `openapi/openapi.yaml` or `openapi/openapi.json`\n\n### Start the tool (Java)\n\nRun the Java application \n```shell\njava -jar target/openapi-request-response-validator.jar\n```\n\nRun the Java application with custom port and spec file\n```shell\njava -jar target/openapi-request-response-validator.jar --server.port=8888 --INPUT_SPECS=/path/to/myopenapi.yaml\n```\n\n### Start the tool (Docker)\n\nYou can run the tool on Docker\n\n```\n# run using default openapi/openapi.yaml or openapi/openapi.json\ndocker run -v $(pwd):/openapi -it --rm --name openapi-request-response-validation \\\n gcatanese/openapi-request-response-validation\n\n# run using custom location of the OpenAPI file\ndocker run -v $(pwd):/openapi -e INPUT_SPECS=/tmp/openapi.yaml \\\n  -it --rm --name openapi-request-response-validation \\\n    gcatanese/openapi-request-response-validation\n```\n\n### Run Postman requests\n\nRun the Postman requests and check the Test tab\n\n![Postman Test Results](doc/postman-test-results.png)\n\n\n\n---\nUsing [Atlassian Swagger Validator](https://bitbucket.org/atlassian/swagger-request-validator/), [Postman](https://postman.com) \nand [Docker](https://docker.com)\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgcatanese%2Fopenapi-request-response-validation","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgcatanese%2Fopenapi-request-response-validation","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgcatanese%2Fopenapi-request-response-validation/lists"}