{"id":16752150,"url":"https://github.com/peltoche/oaichecker","last_synced_at":"2025-04-10T15:52:18.040Z","repository":{"id":87137883,"uuid":"150955772","full_name":"Peltoche/oaichecker","owner":"Peltoche","description":"Test your OpenAPI specs and your server API at the same time","archived":false,"fork":false,"pushed_at":"2018-10-13T13:54:40.000Z","size":96,"stargazers_count":14,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T13:37:41.548Z","etag":null,"topics":["openapi","openapi-validation","swagger","swagger-validator"],"latest_commit_sha":null,"homepage":"","language":"Go","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/Peltoche.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}},"created_at":"2018-09-30T10:08:06.000Z","updated_at":"2022-08-16T13:13:17.000Z","dependencies_parsed_at":"2023-06-15T04:30:42.240Z","dependency_job_id":null,"html_url":"https://github.com/Peltoche/oaichecker","commit_stats":{"total_commits":47,"total_committers":1,"mean_commits":47.0,"dds":0.0,"last_synced_commit":"b2557fb9e859b45624e10cd1cc405c61a67cf5fe"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Peltoche%2Foaichecker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Peltoche%2Foaichecker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Peltoche%2Foaichecker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Peltoche%2Foaichecker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Peltoche","download_url":"https://codeload.github.com/Peltoche/oaichecker/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248245359,"owners_count":21071466,"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":["openapi","openapi-validation","swagger","swagger-validator"],"created_at":"2024-10-13T02:46:01.873Z","updated_at":"2025-04-10T15:52:18.020Z","avatar_url":"https://github.com/Peltoche.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![license](http://img.shields.io/badge/license-Apache%20v2-orange.svg)](https://raw.githubusercontent.com/Peltoche/oaichecker/master/LICENSE)\n[![Build Status](https://travis-ci.org/Peltoche/oaichecker.svg?branch=master)](https://travis-ci.org/Peltoche/oaichecker)\n[![GoDoc](https://godoc.org/github.com/Peltoche/oaichecker?status.svg)](http://godoc.org/github.com/Peltoche/oaichecker)\n[![codecov](https://codecov.io/gh/Peltoche/oaichecker/branch/master/graph/badge.svg)](https://codecov.io/gh/Peltoche/oaichecker)\n[![GolangCI](https://golangci.com/badges/github.com/Peltoche/oaichecker.svg)](https://golangci.com)\n[![Go Report Card](https://goreportcard.com/badge/github.com/Peltoche/oaichecker)](https://goreportcard.com/report/github.com/Peltoche/oaichecker)\n\n\n# OpenAPI Checker\n\nRun you server tests and at the same time check if you tests match with you OpenAPI specs.\n\n\n## Why?\n\nAs a developper I often forget to change the specs after a server modification and\nso my API documentation is always deprecated after 2 commits. In order to fix that\nI have written a little lib which takes you tests HTTP request/responses an\nmatches them against your API specs. If you request doesn't matchs the specs,\nyou request will fail and so you test also fail.\n\n\n## How?\n\nThis lib permits you to generate an http.RoundTripper which can be easily\nintegrated inside you http.Client from you already existing tests.\n\n\n## Example\n\n```go\nimport (\n\t\"github.com/stretchr/testify/assert\"\n\t\"github.com/Peltoche/oaichecker\"\n)\n\nvar client http.Client\n\nfunc init() {\n\t// Loads the specs file.\n\t//\n\t// It contains only a the specs for the endpoint 'GET /pets'.\n\tspecs, err := oaichecker.NewSpecsFromFile(\"./dataset/petstore_minimal.json\")\n\tif err != nil {\n\t\tpanic(err)\n\t}\n\n\t// Create a client which the custom transport\n\tclient = http.Client{\n\t\tTransport: oaichecker.NewTransport(specs),\n\t}\n}\n\nfunc Test_Posting_a_valid_pet(t *testing.T) {\n\t// Make the requests as usual.\n\t//\n\t// In this case the request is valid but the specs are not followed because\n\t// the endpoint 'POST /v2/pet' is not defined inside the specs, only 'GET /pets'.\n\t_, err := client.Post(\"http://petstore.swagger.io/v2/pet\", \"application/json\", strings.NewReader(`{\n\t\"name\": \"doggie\",\n\t\"photoUrls\": [\"some-url\"]}`))\n\n\t// This assert should success but as the specs are not followed, `req` is\n\t// nil and `err` contains the following message:\n\t//\n\t// \"Post http://petstore.swagger.io/v2/pet: operation not defined inside the specs\"\n\tassert.NoError(t, err)\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeltoche%2Foaichecker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpeltoche%2Foaichecker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpeltoche%2Foaichecker/lists"}