openapi
OpenAPI schema customization and code sample generation.
Functions
|
Create custom OpenAPI schema with service metadata and customizations. |
|
Generate code sample for a given language, method, and path. |
Module Contents
- openapi.create_custom_openapi_schema(app, logger)
Create custom OpenAPI schema with service metadata and customizations.
- openapi.generate_code_sample(language, method, path, parameters, base_url='')
Generate code sample for a given language, method, and path.
Uses Jinja2 templates to generate code samples dynamically at runtime. The generated code includes a placeholder __API_SERVER_URL__ that will be replaced with the actual URL during documentation rendering.
- Parameters:
language (str) – The programming language (shell, python, go, js)
method (str) – HTTP method (GET, POST, etc.)
path (str) – API endpoint path
parameters (list) – List of OpenAPI parameter definitions
base_url (str) – Base URL for the API (optional, defaults to empty string)
- Returns:
Generated code sample as a string with __API_SERVER_URL__ placeholder
- Return type:
str