{"library":"openapi-generator-cli","title":"OpenAPI Generator CLI","description":"The `openapi-generator-cli` Python package provides a command-line interface (CLI) for the OpenAPI Generator, a robust tool that automatically generates API client libraries (SDKs), server stubs, documentation, and configuration from an OpenAPI Specification (supporting both 2.0 and 3.x). The Python package acts as a thin wrapper around the official Java-based OpenAPI Generator, downloading and executing the appropriate JAR file. It maintains an active development pace, with new versions often released daily to mirror updates in the core Java project, typically including numerous enhancements, bug fixes, and sometimes breaking changes with fallbacks.","language":"python","status":"active","last_verified":"Mon Apr 13","install":{"commands":["pip install openapi-generator-cli","pip install openapi-generator-cli[jdk4py]"],"cli":{"name":"openapi-generator-cli","version":"Traceback (most recent call last):"}},"imports":[],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"pip install openapi-generator-cli\n\n# Check installed version\nopenapi-generator-cli version\n\n# Generate a Python client from a public OpenAPI specification\n# This will create a directory named 'my_python_client' containing the generated SDK\nopenapi-generator-cli generate \\\n  -i https://petstore.swagger.io/v2/swagger.json \\\n  -g python \\\n  -o my_python_client\n\n# To use the generated client (example, assuming 'my_python_client' was created):\n# cd my_python_client\n# pip install .\n#\n# Then in a Python script:\n# from openapi_client import api_client, configuration\n# from openapi_client.api import pet_api\n#\n# # Configure API key authorization: api_key\n# config = configuration.Configuration()\n# config.api_key['api_key'] = 'YOUR_API_KEY_HERE'\n#\n# # Create an API client\n# client = api_client.ApiClient(configuration=config)\n# api = pet_api.PetApi(client)\n#\n# # Example: List pets (assuming the generated client structure)\n# # try:\n# #     all_pets = api.find_pets_by_status(status=['available'])\n# #     print(all_pets)\n# # except Exception as e:\n# #     print(f\"Error: {e}\")","lang":"bash","description":"This quickstart demonstrates how to install the `openapi-generator-cli` and use it to generate a Python client library from a public OpenAPI Specification. The `openapi-generator-cli` itself is a command-line tool, and direct Python imports are not typically used for the generator. Instead, you execute the CLI command to produce source code (e.g., an SDK) in a chosen language, which you then integrate into your project and import as a separate library. Replace `https://petstore.swagger.io/v2/swagger.json` with your own OpenAPI spec URL or file path, and adjust the generator (`-g python`) and output directory (`-o my_python_client`) as needed. The commented Python code provides an example of how a *generated* Python client might be used.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}