Files
docs/mcp/openapi-first/modules/openapi_first.codegen.json

51 lines
3.5 KiB
JSON

{
"module": "openapi_first.codegen",
"content": {
"path": "openapi_first.codegen",
"docstring": "# Summary\n\nCore logic for generating Python source code from OpenAPI specifications.\n\nThis module provides reusable utilities for code generation, specifically\ngenerating Pydantic models and route handler stubs from OpenAPI 3.x schema\ndefinitions.",
"objects": {
"Path": {
"name": "Path",
"kind": "alias",
"path": "openapi_first.codegen.Path",
"signature": "<bound method Alias.signature of Alias('Path', 'pathlib.Path')>",
"docstring": null
},
"InputFileType": {
"name": "InputFileType",
"kind": "alias",
"path": "openapi_first.codegen.InputFileType",
"signature": "<bound method Alias.signature of Alias('InputFileType', 'datamodel_code_generator.InputFileType')>",
"docstring": null
},
"PythonVersion": {
"name": "PythonVersion",
"kind": "alias",
"path": "openapi_first.codegen.PythonVersion",
"signature": "<bound method Alias.signature of Alias('PythonVersion', 'datamodel_code_generator.PythonVersion')>",
"docstring": null
},
"generate": {
"name": "generate",
"kind": "alias",
"path": "openapi_first.codegen.generate",
"signature": "<bound method Alias.signature of Alias('generate', 'datamodel_code_generator.generate')>",
"docstring": null
},
"generate_routes": {
"name": "generate_routes",
"kind": "function",
"path": "openapi_first.codegen.generate_routes",
"signature": "<bound method Alias.signature of Alias('generate_routes', 'openapi_first.codegen_routes.generate_routes')>",
"docstring": "Generate route handler stubs from an OpenAPI specification.\n\nCreates one ``<resource>.py`` file per resource in *output_dir*.\nResources are derived from the first path segment (e.g. ``/pets``\nand ``/pets/{id}`` both group under ``pets``).\n\nArgs:\n spec_path (Path):\n Path to the OpenAPI specification file (YAML or JSON).\n output_dir (Path):\n Directory where the generated route files are written.\n Created automatically if it does not exist.\n use_models (bool, optional):\n If ``True``, import Pydantic models from *models_module*\n for request-body schemas referenced via ``$ref``.\n models_module (str, optional):\n Dotted Python module path from which to import models\n (e.g. ``\"models\"``, ``\"app.models\"``).\n\nReturns:\n list[Path]:\n Absolute paths of every generated route file.\n\nRaises:\n OpenAPISpecLoadError:\n If the spec cannot be loaded or validated.\n ValueError:\n If any operation is missing ``operationId``."
},
"generate_models": {
"name": "generate_models",
"kind": "function",
"path": "openapi_first.codegen.generate_models",
"signature": "<bound method Function.signature of Function('generate_models', 22, 51)>",
"docstring": "Generate Pydantic models from an OpenAPI specification.\n\nArgs:\n spec_path (Path):\n Path to the OpenAPI specification file (YAML or JSON).\n output_path (Path):\n Path where the generated Python code should be written.\n pydantic_version (int, optional):\n The Pydantic version to target (1 or 2). Defaults to 2.\n\nNotes:\n **Reusability:**\n This function is designed to be used by the CLI and can be\n exposed as an MCP tool without modification."
}
}
}
}