{"id":14986566,"url":"https://github.com/olipratt/swagger-conformance","last_synced_at":"2025-04-11T20:32:04.136Z","repository":{"id":57472622,"uuid":"84729850","full_name":"olipratt/swagger-conformance","owner":"olipratt","description":"Python based tool for testing whether your API conforms to its Swagger schema","archived":false,"fork":false,"pushed_at":"2018-09-29T06:59:22.000Z","size":190,"stargazers_count":53,"open_issues_count":5,"forks_count":11,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-25T18:16:37.692Z","etag":null,"topics":["fuzzing","open-api","property-based-testing","swagger","swagger-schema"],"latest_commit_sha":null,"homepage":"http://swagger-conformance.readthedocs.io/en/latest/","language":"Python","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/olipratt.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-03-12T13:59:37.000Z","updated_at":"2024-09-07T19:33:39.000Z","dependencies_parsed_at":"2022-09-19T07:52:22.899Z","dependency_job_id":null,"html_url":"https://github.com/olipratt/swagger-conformance","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olipratt%2Fswagger-conformance","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olipratt%2Fswagger-conformance/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olipratt%2Fswagger-conformance/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/olipratt%2Fswagger-conformance/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/olipratt","download_url":"https://codeload.github.com/olipratt/swagger-conformance/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248476380,"owners_count":21110265,"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":["fuzzing","open-api","property-based-testing","swagger","swagger-schema"],"created_at":"2024-09-24T14:13:09.149Z","updated_at":"2025-04-11T20:31:59.113Z","avatar_url":"https://github.com/olipratt.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# swagger-conformance\n\n[![PyPI version](https://badge.fury.io/py/swagger-conformance.svg)](https://badge.fury.io/py/swagger-conformance)\n[![Build Status](https://travis-ci.org/olipratt/swagger-conformance.svg?branch=master)](https://travis-ci.org/olipratt/swagger-conformance)\n[![codecov](https://codecov.io/gh/olipratt/swagger-conformance/branch/master/graph/badge.svg)](https://codecov.io/gh/olipratt/swagger-conformance)\n[![docs](https://readthedocs.org/projects/swagger-conformance/badge/?version=latest)](http://swagger-conformance.readthedocs.io/en/latest/)\n\n[![PyPI Versions](https://img.shields.io/pypi/pyversions/swagger-conformance.svg)](https://pypi.python.org/pypi/swagger-conformance)\n[![PyPI License](https://img.shields.io/pypi/l/swagger-conformance.svg)](https://pypi.python.org/pypi/swagger-conformance)\n\nYou have a Swagger (aka OpenAPI) schema defining an API you provide - but does your API really conform to that schema, and does it correctly handle all valid inputs?\n\n`swaggerconformance` combines the power of `hypothesis` for property based / fuzz testing with `pyswagger` to explore all corners of your API - testing its conformance to its specification.\n\n## Purpose\n\nA Swagger/OpenAPI Spec allows you to carefully define what things are and aren't valid for your API to consume and produce. This tool takes that definition, and tries to make requests exploring all parts of the API while strictly adhering to the schema. Its aim is to find any places where your application fails to adhere to its own spec, or even just falls over entirely, so you can fix them up.\n\n_This is not a complete fuzz tester of your HTTP interface e.g. sending complete garbage, or to non-existent endpoints, etc. It's aiming to make sure that any valid client, using your API exactly as you specify, can't break it._\n\n## Setup\n\nEither install with `pip install swagger-conformance`, or manually clone this repository and from inside it install dependencies with `pip install -r requirements.txt`.\n\n## Usage\n\nAfter setup, the simplest test you can run against your API is just the following from the command line:\n\n```bash\npython -m swaggerconformance 'http://example.com/api/schema.json'\n```\n\nwhere the URL should resolve to your swagger schema, or it can be a path to the file on disk.\n\nThis basic test tries all your API operations looking for errors. For explanation of the results and running more thorough tests, including sequences of API calls and defining your custom data types, [see the examples](https://github.com/olipratt/swagger-conformance/tree/master/examples).\n\n## Documentation\n\nFull documentation, including the example walkthroughs mentioned above and API documentation, is [available here](http://swagger-conformance.readthedocs.io/en/latest/).\n\n## Wait, I don't get it, what does this thing do?\n\nIn short, it lets you generate example values for parameters to your Swagger API operations, make API requests using these values, and verify the responses.\n\nFor example, take the standard [petstore API](http://petstore.swagger.io/) example. At the time of writing, that has an endpoint `/pet` with a `PUT` method operation that takes a relatively complicated `body` parameter.\n\nWith just a little code, we can load in the swagger schema for that API, access the operation we care about, and generate example parameters for that operation:\n\n```python\n\u003e\u003e\u003e import swaggerconformance\n\u003e\u003e\u003e\n\u003e\u003e\u003e client = swaggerconformance.client.Client('http://petstore.swagger.io/v2/swagger.json')\n\u003e\u003e\u003e\n\u003e\u003e\u003e strategy_factory = swaggerconformance.strategies.StrategyFactory()\n\u003e\u003e\u003e operation = client.api.endpoints[\"/pet\"][\"put\"]\n\u003e\u003e\u003e strategy = operation.parameters_strategy(strategy_factory)\n\u003e\u003e\u003e strategy.example()\n{\n  'body':{\n    'id':110339,\n    'name':'\\U00052ea5\\x9d\\ua79d\\x92\\x13\\U000f7c436!\\U000aa3c5R\\U0005b40e\\n',\n    'photoUrls':[\n      '\\ua9d9\\U0003fb3a\\x13\\U00025c1c\\U000974a8\\u3497\\U000515fa\\n',\n      \"\\U000b38a4\u003e*\\u6683'\\U0002cd8f\\x0f\\n\"\n    ],\n    'status':'sold',\n    'category':{\n      'id':-22555826027447\n    },\n    'tags':[\n      {\n        'id':-172930,\n        'name':'\\U000286df\\u04dc\\U00033563\\u696d\\U00055ba8\\x89H'\n      }\n    ]\n  }\n}\n\u003e\u003e\u003e\n```\n\nSee [the examples](https://github.com/olipratt/swagger-conformance/tree/master/examples) for more details, and how to make requests against an API using these parameter values.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folipratt%2Fswagger-conformance","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Folipratt%2Fswagger-conformance","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Folipratt%2Fswagger-conformance/lists"}