{"id":3190,"library":"openapi-python-client","title":"OpenAPI Python Client Generator","description":"OpenAPI Python Client Generator is a Python library and CLI tool that generates modern, type-hinted Python clients from OpenAPI specifications. It supports both OpenAPI v2 (Swagger) and v3 specifications, generating Pydantic-based models and httpx-based clients. It's actively maintained with frequent releases, currently at version 0.28.3.","status":"active","version":"0.28.3","language":"en","source_language":"en","source_url":"https://github.com/openapi-generators/openapi-python-client","tags":["openapi","client generation","api client","code generation","pydantic","httpx"],"install":[{"cmd":"pip install openapi-python-client","lang":"bash","label":"Install core library"}],"dependencies":[{"reason":"Used for data models in generated clients. Version 2.x is preferred since 0.21.0.","package":"pydantic","optional":false},{"reason":"Used as the HTTP client for generated clients. Required since 0.23.0.","package":"httpx","optional":false}],"imports":[{"note":"For programmatic client generation. Most common usage is via the CLI command `openapi-python-client generate`.","symbol":"create_new_client","correct":"from openapi_python_client.create_new_client import create_new_client"}],"quickstart":{"code":"openapi-python-client generate --url https://petstore.swagger.io/v2/swagger.json --path my-api-client\n\n# The above command generates a client in the 'my-api-client' directory.\n# Example usage of the generated client (assuming 'my-api-client' is in your PYTHONPATH):\n# import my_api_client.client as my_client\n# client = my_client.Client(base_url=\"https://petstore.swagger.io/v2\")\n# # You can now use client.pet, client.store, etc.\n# response = client.pet.find_pets_by_status(status=\"available\")\n# if response.status_code == 200:\n#     pets = response.parsed\n#     for pet in pets:\n#         print(pet.name)","lang":"bash","description":"Generates a Python client for the Petstore API from its OpenAPI specification. The primary interaction with openapi-python-client is via its command-line interface. The generated client is then imported and used like a standard Python library."},"warnings":[{"fix":"The `name` argument was renamed to `path` in `create_new_client`. The output directory structure also changed from `{output_path}` to `{output_path}/{project_name}/`. Adjust programmatic calls and expect a new directory layout.","message":"Breaking changes to `create_new_client` arguments and output directory structure.","severity":"breaking","affected_versions":">=0.28.0"},{"fix":"`BaseModel` was replaced by `PydanticBaseModel` and `TypingBaseModel`. The `from_dict` method was removed from models, and `_get_kwargs` was renamed to `_prepped_request` on `_Endpoint` classes. Update any custom code interacting directly with these internal components.","message":"Core model classes and methods were renamed or removed.","severity":"breaking","affected_versions":">=0.27.0"},{"fix":"Prior to 0.23.0, `httpx` was optional and `mypy` generation could be disabled. Since 0.23.0, `httpx` is a direct dependency and `mypy` type hints are always generated. Ensure your environment allows for these dependencies and integrate mypy checks into your workflow if not already.","message":"`httpx` and `mypy` became mandatory dependencies/generated code.","severity":"breaking","affected_versions":">=0.23.0"},{"fix":"Clients generated with `openapi-python-client` versions 0.21.0 and above require Pydantic V2. If you have existing code using Pydantic V1 and wish to regenerate your client, you might need to manage Pydantic versions carefully or update your application to Pydantic V2.","message":"Pydantic V2 support introduced, requiring Pydantic >= 2.0.","severity":"breaking","affected_versions":">=0.21.0"},{"fix":"While `openapi-python-client` attempts to handle complex types, especially those involving `oneOf`/`anyOf`/`allOf` or discriminator patterns, the resulting Pydantic models can sometimes be difficult to work with or might not perfectly reflect the intended schema logic. Always review the generated client's models and their types, and test thoroughly. Custom templates can be used for advanced control.","message":"Complex OpenAPI schemas (e.g., `oneOf`, `allOf`, discriminators) can lead to challenging type generation.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}