@aws/nx-plugin 1.0.0-rc.12 → 1.0.0-rc.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE-THIRD-PARTY +81 -3
- package/generators.json +28 -1
- package/package.json +2 -2
- package/src/connection/generator.d.ts +1 -1
- package/src/connection/generator.js +58 -42
- package/src/connection/generator.js.map +1 -1
- package/src/infra/app/__snapshots__/generator.spec.ts.snap +16 -16
- package/src/infra/app/generator.js +4 -4
- package/src/infra/app/generator.js.map +1 -1
- package/src/preset/__snapshots__/generator.spec.ts.snap +4 -2
- package/src/py/agent/__snapshots__/generator.spec.ts.snap +574 -5
- package/src/py/agent/files/http/init.py.template +5 -23
- package/src/py/agent/generator.js +27 -22
- package/src/py/agent/generator.js.map +1 -1
- package/src/py/dynamodb/__snapshots__/generator.spec.ts.snap +1486 -0
- package/src/py/dynamodb/agent-connection/__snapshots__/generator.spec.ts.snap +45 -0
- package/src/py/dynamodb/agent-connection/generator.d.ts +10 -0
- package/src/py/dynamodb/agent-connection/generator.js +39 -0
- package/src/py/dynamodb/agent-connection/generator.js.map +1 -0
- package/src/py/dynamodb/agent-connection/schema.d.ts +14 -0
- package/src/py/dynamodb/agent-connection/schema.json +22 -0
- package/src/py/dynamodb/fast-api-connection/__snapshots__/generator.spec.ts.snap +23 -0
- package/src/py/dynamodb/fast-api-connection/generator.d.ts +10 -0
- package/src/py/dynamodb/fast-api-connection/generator.js +37 -0
- package/src/py/dynamodb/fast-api-connection/generator.js.map +1 -0
- package/src/py/dynamodb/fast-api-connection/schema.d.ts +12 -0
- package/src/py/dynamodb/fast-api-connection/schema.json +18 -0
- package/src/py/dynamodb/files/__name__/__init__.py.template +6 -0
- package/src/py/dynamodb/files/__name__/client.py.template +39 -0
- package/src/py/dynamodb/files/__name__/entities/__init__.py.template +4 -0
- package/src/py/dynamodb/files/__name__/entities/base.py.template +63 -0
- package/src/py/dynamodb/files/__name__/entities/example.py.template +64 -0
- package/src/py/dynamodb/files/config.json.template +24 -0
- package/src/py/dynamodb/generator.d.ts +10 -0
- package/src/py/dynamodb/generator.js +106 -0
- package/src/py/dynamodb/generator.js.map +1 -0
- package/src/py/dynamodb/mcp-server-connection/__snapshots__/generator.spec.ts.snap +45 -0
- package/src/py/dynamodb/mcp-server-connection/generator.d.ts +10 -0
- package/src/py/dynamodb/mcp-server-connection/generator.js +39 -0
- package/src/py/dynamodb/mcp-server-connection/generator.js.map +1 -0
- package/src/py/dynamodb/mcp-server-connection/schema.d.ts +14 -0
- package/src/py/dynamodb/mcp-server-connection/schema.json +22 -0
- package/src/py/dynamodb/schema.d.ts +15 -0
- package/src/py/dynamodb/schema.json +70 -0
- package/src/py/fast-api/__snapshots__/generator.spec.ts.snap +5 -22
- package/src/py/fast-api/files/app/__name__/init.py.template +5 -22
- package/src/py/mcp-server/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/agent/__snapshots__/generator.spec.ts.snap +564 -0
- package/src/ts/agent/generator.js +23 -19
- package/src/ts/agent/generator.js.map +1 -1
- package/src/ts/dynamodb/__snapshots__/generator.spec.ts.snap +303 -512
- package/src/ts/dynamodb/files/config.json.template +24 -0
- package/src/ts/dynamodb/files/src/client.ts.template +26 -10
- package/src/ts/dynamodb/files/src/index.ts.template +0 -8
- package/src/ts/dynamodb/generator.js +15 -12
- package/src/ts/dynamodb/generator.js.map +1 -1
- package/src/ts/dynamodb/schema.d.ts +1 -0
- package/src/ts/dynamodb/schema.json +20 -2
- package/src/ts/mcp-server/__snapshots__/generator.spec.ts.snap +1 -1
- package/src/ts/react-website/app/__snapshots__/generator.spec.ts.snap +86 -39
- package/src/utils/agent-chat/agent-chat.d.ts +31 -0
- package/src/utils/agent-chat/agent-chat.js +30 -0
- package/src/utils/agent-chat/agent-chat.js.map +1 -0
- package/src/utils/agent-chat/files/a2a/chat.ts.template +33 -0
- package/src/utils/agent-chat/files/ag-ui/chat.ts.template +17 -0
- package/src/utils/agent-chat/files/common/agentcore.ts.template +81 -0
- package/src/utils/agent-chat/files/http-py/chat.ts.template +43 -0
- package/src/utils/agent-chat/files/http-ts/chat.ts.template +54 -0
- package/src/utils/dynamodb-constructs/dynamodb-constructs.d.ts +0 -1
- package/src/utils/dynamodb-constructs/dynamodb-constructs.js.map +1 -1
- package/src/utils/dynamodb-constructs/files/cdk/app/dynamodb/__nameKebabCase__.ts.template +12 -13
- package/src/utils/dynamodb-constructs/files/terraform/app/dynamodb/__nameKebabCase__/__nameKebabCase__.tf.template +3 -3
- package/src/{ts/dynamodb/files/scripts → utils/files/common/scripts/src/dynamodb}/create-local-table.ts.template +63 -36
- package/src/utils/files/common/scripts/src/dynamodb/pull-image.ts.template +13 -0
- package/src/{ts/dynamodb/files/scripts → utils/files/common/scripts/src/dynamodb}/start-container.ts.template +28 -18
- package/src/utils/port.d.ts +6 -5
- package/src/utils/port.js +7 -5
- package/src/utils/port.js.map +1 -1
- package/src/utils/shared-constructs-constants.d.ts +1 -0
- package/src/utils/shared-constructs-constants.js +2 -1
- package/src/utils/shared-constructs-constants.js.map +1 -1
- package/src/utils/shared-dynamodb-scripts.d.ts +11 -0
- package/src/utils/shared-dynamodb-scripts.js +23 -0
- package/src/utils/shared-dynamodb-scripts.js.map +1 -0
- package/src/utils/shared-infra-scripts.d.ts +11 -0
- package/src/utils/shared-infra-scripts.js +35 -0
- package/src/utils/shared-infra-scripts.js.map +1 -0
- package/src/utils/shared-scripts.d.ts +1 -4
- package/src/utils/shared-scripts.js +2 -23
- package/src/utils/shared-scripts.js.map +1 -1
- package/src/utils/versions.d.ts +45 -44
- package/src/utils/versions.js +44 -43
- package/src/utils/versions.js.map +1 -1
- package/src/py/agent/scripts/http/chat.ts.template +0 -38
- package/src/ts/agent/scripts/http/chat.ts.template +0 -35
- package/src/ts/dynamodb/files/dynamodb.config.json +0 -14
- package/src/ts/dynamodb/files/scripts/pull-image.ts.template +0 -15
- package/src/ts/dynamodb/files/src/constants.ts.template +0 -9
- /package/src/utils/files/common/scripts/src/{index.ts.template → infra/index.ts.template} +0 -0
- /package/src/utils/files/common/scripts/src/{infra-deploy.ts.template → infra/infra-deploy.ts.template} +0 -0
- /package/src/utils/files/common/scripts/src/{infra-destroy.ts.template → infra/infra-destroy.ts.template} +0 -0
- /package/src/utils/files/common/scripts/src/{stage-credentials → infra/stage-credentials}/cdk-command.ts.template +0 -0
- /package/src/utils/files/common/scripts/src/{stage-credentials → infra/stage-credentials}/credentials.ts.template +0 -0
- /package/src/utils/files/common/scripts/src/{stage-credentials → infra/stage-credentials}/run.ts.template +0 -0
- /package/src/utils/files/common/scripts/src/{stage-credentials → infra/stage-credentials}/stage-parser.ts.template +0 -0
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.pyDynamoDBMcpServerConnectionGenerator = exports.PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
6
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
7
|
+
*/
|
|
8
|
+
const devkit_1 = require("@nx/devkit");
|
|
9
|
+
const format_1 = require("../../../utils/format");
|
|
10
|
+
const metrics_1 = require("../../../utils/metrics");
|
|
11
|
+
const nx_1 = require("../../../utils/nx");
|
|
12
|
+
const nxlv_python_1 = require("../../../utils/nxlv-python");
|
|
13
|
+
const py_1 = require("../../../utils/py");
|
|
14
|
+
exports.PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO = (0, nx_1.getGeneratorInfo)(__filename);
|
|
15
|
+
const pyDynamoDBMcpServerConnectionGenerator = async (tree, options) => {
|
|
16
|
+
const sourceProject = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.sourceProject);
|
|
17
|
+
const targetProject = (0, nx_1.readProjectConfigurationUnqualified)(tree, options.targetProject);
|
|
18
|
+
(0, py_1.addWorkspaceDependencyToPyProject)(tree, sourceProject.root, targetProject.name);
|
|
19
|
+
const mcpServerName = options.sourceComponent?.name ?? 'mcp-server';
|
|
20
|
+
const serveLocalTarget = `${mcpServerName}-serve-local`;
|
|
21
|
+
if (sourceProject.targets?.[serveLocalTarget]) {
|
|
22
|
+
(0, nx_1.addDependencyToTargetIfNotPresent)(sourceProject, serveLocalTarget, {
|
|
23
|
+
projects: [targetProject.name],
|
|
24
|
+
target: 'serve-local',
|
|
25
|
+
});
|
|
26
|
+
(0, devkit_1.updateProjectConfiguration)(tree, sourceProject.name, sourceProject);
|
|
27
|
+
}
|
|
28
|
+
await (0, metrics_1.addGeneratorMetricsIfApplicable)(tree, [
|
|
29
|
+
exports.PY_DYNAMODB_MCP_SERVER_CONNECTION_GENERATOR_INFO,
|
|
30
|
+
]);
|
|
31
|
+
await (0, format_1.formatFilesInSubtree)(tree);
|
|
32
|
+
return async () => {
|
|
33
|
+
(0, devkit_1.installPackagesTask)(tree);
|
|
34
|
+
await new nxlv_python_1.UVProvider(tree.root, new nxlv_python_1.Logger(), tree).install();
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
exports.pyDynamoDBMcpServerConnectionGenerator = pyDynamoDBMcpServerConnectionGenerator;
|
|
38
|
+
exports.default = exports.pyDynamoDBMcpServerConnectionGenerator;
|
|
39
|
+
//# sourceMappingURL=generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generator.js","sourceRoot":"","sources":["../../../../../../../packages/nx-plugin/src/py/dynamodb/mcp-server-connection/generator.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,uCAKoB;AACpB,kDAA6D;AAC7D,oDAAyE;AACzE,0CAK2B;AAC3B,4DAAgE;AAChE,0CAAsE;AAGzD,QAAA,gDAAgD,GAC3D,IAAA,qBAAgB,EAAC,UAAU,CAAC,CAAC;AAExB,MAAM,sCAAsC,GAAG,KAAK,EACzD,IAAU,EACV,OAAqD,EACzB,EAAE;IAC9B,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ,OAAO,CAAC,aAAa,CACtB,CAAC;IACF,MAAM,aAAa,GAAG,IAAA,wCAAmC,EACvD,IAAI,EACJ,OAAO,CAAC,aAAa,CACtB,CAAC;IAEF,IAAA,sCAAiC,EAC/B,IAAI,EACJ,aAAa,CAAC,IAAI,EAClB,aAAa,CAAC,IAAK,CACpB,CAAC;IAEF,MAAM,aAAa,GAAG,OAAO,CAAC,eAAe,EAAE,IAAI,IAAI,YAAY,CAAC;IACpE,MAAM,gBAAgB,GAAG,GAAG,aAAa,cAAc,CAAC;IAExD,IAAI,aAAa,CAAC,OAAO,EAAE,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC9C,IAAA,sCAAiC,EAAC,aAAa,EAAE,gBAAgB,EAAE;YACjE,QAAQ,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC;YAC9B,MAAM,EAAE,aAAa;SACtB,CAAC,CAAC;QACH,IAAA,mCAA0B,EAAC,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,aAAa,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,IAAA,yCAA+B,EAAC,IAAI,EAAE;QAC1C,wDAAgD;KACjD,CAAC,CAAC;IACH,MAAM,IAAA,6BAAoB,EAAC,IAAI,CAAC,CAAC;IACjC,OAAO,KAAK,IAAI,EAAE;QAChB,IAAA,4BAAmB,EAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,IAAI,wBAAU,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,oBAAM,EAAE,EAAE,IAAI,CAAC,CAAC,OAAO,EAAE,CAAC;IAChE,CAAC,CAAC;AACJ,CAAC,CAAC;AAtCW,QAAA,sCAAsC,0CAsCjD;AAEF,kBAAe,8CAAsC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { ComponentMetadata } from '../../../utils/nx';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* TypeScript types for options defined in schema.json
|
|
9
|
+
*/
|
|
10
|
+
export interface PyDynamoDBMcpServerConnectionGeneratorSchema {
|
|
11
|
+
sourceProject: string;
|
|
12
|
+
targetProject: string;
|
|
13
|
+
sourceComponent?: ComponentMetadata;
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "py#dynamodb#mcp-server-connection",
|
|
4
|
+
"title": "py#dynamodb#mcp-server-connection",
|
|
5
|
+
"description": "Connect a py#mcp-server to a py#dynamodb project",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"sourceProject": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "The project containing the py#mcp-server to connect from"
|
|
11
|
+
},
|
|
12
|
+
"targetProject": {
|
|
13
|
+
"type": "string",
|
|
14
|
+
"description": "The py#dynamodb project to connect to"
|
|
15
|
+
},
|
|
16
|
+
"sourceComponent": {
|
|
17
|
+
"type": "string",
|
|
18
|
+
"description": "The MCP server component name"
|
|
19
|
+
}
|
|
20
|
+
},
|
|
21
|
+
"required": ["sourceProject", "targetProject"]
|
|
22
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
3
|
+
* SPDX-License-Identifier: Apache-2.0
|
|
4
|
+
*/
|
|
5
|
+
import { IacOption } from '../../utils/iac';
|
|
6
|
+
|
|
7
|
+
export interface PyDynamoDBGeneratorSchema {
|
|
8
|
+
name: string;
|
|
9
|
+
directory?: string;
|
|
10
|
+
subDirectory?: string;
|
|
11
|
+
framework: 'pynamodb';
|
|
12
|
+
tableName?: string;
|
|
13
|
+
infra: 'dynamodb' | 'none';
|
|
14
|
+
iac: IacOption;
|
|
15
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/schema",
|
|
3
|
+
"$id": "py#dynamodb",
|
|
4
|
+
"title": "py#dynamodb",
|
|
5
|
+
"description": "Create a Python DynamoDB project",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"properties": {
|
|
8
|
+
"name": {
|
|
9
|
+
"type": "string",
|
|
10
|
+
"description": "Name of the DynamoDB project to generate",
|
|
11
|
+
"$default": {
|
|
12
|
+
"$source": "argv",
|
|
13
|
+
"index": 0
|
|
14
|
+
},
|
|
15
|
+
"x-priority": "important",
|
|
16
|
+
"x-prompt": "What name would you like your DynamoDB project to have? i.e: MyTable"
|
|
17
|
+
},
|
|
18
|
+
"directory": {
|
|
19
|
+
"type": "string",
|
|
20
|
+
"description": "The directory to store the project in.",
|
|
21
|
+
"default": "packages",
|
|
22
|
+
"x-priority": "important",
|
|
23
|
+
"x-prompt": "Which directory do you want to create the project in?"
|
|
24
|
+
},
|
|
25
|
+
"subDirectory": {
|
|
26
|
+
"type": "string",
|
|
27
|
+
"description": "The sub directory the project is placed in. By default this is the project name.",
|
|
28
|
+
"x-prompt": "Which sub directory do you want to create the project in? (By default this is the project name)"
|
|
29
|
+
},
|
|
30
|
+
"framework": {
|
|
31
|
+
"type": "string",
|
|
32
|
+
"enum": ["pynamodb"],
|
|
33
|
+
"default": "pynamodb",
|
|
34
|
+
"description": "The framework to use for DynamoDB entities.",
|
|
35
|
+
"x-priority": "important",
|
|
36
|
+
"x-prompt": {
|
|
37
|
+
"message": "Which framework would you like to use for DynamoDB entities?",
|
|
38
|
+
"type": "list",
|
|
39
|
+
"items": [
|
|
40
|
+
{
|
|
41
|
+
"value": "pynamodb",
|
|
42
|
+
"label": "PynamoDB"
|
|
43
|
+
}
|
|
44
|
+
],
|
|
45
|
+
"default": "pynamodb"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
"tableName": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"description": "The DynamoDB table name. Auto-generated if not specified."
|
|
51
|
+
},
|
|
52
|
+
"infra": {
|
|
53
|
+
"type": "string",
|
|
54
|
+
"enum": ["dynamodb", "none"],
|
|
55
|
+
"default": "dynamodb",
|
|
56
|
+
"description": "Infrastructure to provision for the DynamoDB table.",
|
|
57
|
+
"x-priority": "important",
|
|
58
|
+
"x-prompt": "Which infrastructure would you like to provision?"
|
|
59
|
+
},
|
|
60
|
+
"iac": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "The preferred IaC provider. By default this is inherited from your initial selection.",
|
|
63
|
+
"enum": ["inherit", "cdk", "terraform"],
|
|
64
|
+
"x-priority": "important",
|
|
65
|
+
"default": "inherit",
|
|
66
|
+
"x-prompt": "Which provider would you like to manage your infrastructure? (default: Inherit)"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"required": ["name"]
|
|
70
|
+
}
|
|
@@ -14,7 +14,6 @@ from urllib.parse import urlparse
|
|
|
14
14
|
from aws_lambda_powertools import Logger, Metrics, Tracer
|
|
15
15
|
from aws_lambda_powertools.metrics import MetricUnit
|
|
16
16
|
from fastapi import FastAPI, Request, Response
|
|
17
|
-
from fastapi.openapi.utils import get_openapi
|
|
18
17
|
from fastapi.responses import JSONResponse, StreamingResponse
|
|
19
18
|
from fastapi.routing import APIRoute
|
|
20
19
|
from pydantic import BaseModel
|
|
@@ -81,7 +80,11 @@ class JsonStreamingResponse(StreamingResponse):
|
|
|
81
80
|
}
|
|
82
81
|
|
|
83
82
|
|
|
84
|
-
app = FastAPI(
|
|
83
|
+
app = FastAPI(
|
|
84
|
+
title="TestApi",
|
|
85
|
+
responses={500: {"model": InternalServerErrorDetails}},
|
|
86
|
+
generate_unique_id_function=lambda route: route.name,
|
|
87
|
+
)
|
|
85
88
|
|
|
86
89
|
|
|
87
90
|
# Add cors middleware
|
|
@@ -187,26 +190,6 @@ class LoggerRouteHandler(APIRoute):
|
|
|
187
190
|
|
|
188
191
|
|
|
189
192
|
app.router.route_class = LoggerRouteHandler
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
def custom_openapi() -> dict[str, Any]:
|
|
193
|
-
if app.openapi_schema:
|
|
194
|
-
return app.openapi_schema
|
|
195
|
-
for route in app.routes:
|
|
196
|
-
if isinstance(route, APIRoute):
|
|
197
|
-
route.operation_id = route.name
|
|
198
|
-
openapi_schema = get_openapi(
|
|
199
|
-
title=app.title,
|
|
200
|
-
version=app.version,
|
|
201
|
-
openapi_version=app.openapi_version,
|
|
202
|
-
description=app.description,
|
|
203
|
-
routes=app.routes,
|
|
204
|
-
)
|
|
205
|
-
app.openapi_schema = openapi_schema
|
|
206
|
-
return app.openapi_schema
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
app.openapi = custom_openapi # ty: ignore[invalid-assignment]
|
|
210
193
|
",
|
|
211
194
|
"apps/test_api/proj_test_api/main.py": "import uvicorn
|
|
212
195
|
from pydantic import BaseModel
|
|
@@ -8,7 +8,6 @@ from urllib.parse import urlparse
|
|
|
8
8
|
from aws_lambda_powertools import Logger, Metrics, Tracer
|
|
9
9
|
from aws_lambda_powertools.metrics import MetricUnit
|
|
10
10
|
from fastapi import FastAPI, Request, Response
|
|
11
|
-
from fastapi.openapi.utils import get_openapi
|
|
12
11
|
from fastapi.responses import JSONResponse, StreamingResponse
|
|
13
12
|
from fastapi.routing import APIRoute
|
|
14
13
|
from pydantic import BaseModel
|
|
@@ -73,7 +72,11 @@ class JsonStreamingResponse(StreamingResponse):
|
|
|
73
72
|
}
|
|
74
73
|
|
|
75
74
|
|
|
76
|
-
app = FastAPI(
|
|
75
|
+
app = FastAPI(
|
|
76
|
+
title="<%= apiNameClassName %>",
|
|
77
|
+
responses={500: {"model": InternalServerErrorDetails}},
|
|
78
|
+
generate_unique_id_function=lambda route: route.name,
|
|
79
|
+
)
|
|
77
80
|
|
|
78
81
|
|
|
79
82
|
# Add cors middleware
|
|
@@ -174,23 +177,3 @@ class LoggerRouteHandler(APIRoute):
|
|
|
174
177
|
|
|
175
178
|
|
|
176
179
|
app.router.route_class = LoggerRouteHandler
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
def custom_openapi() -> dict[str, Any]:
|
|
180
|
-
if app.openapi_schema:
|
|
181
|
-
return app.openapi_schema
|
|
182
|
-
for route in app.routes:
|
|
183
|
-
if isinstance(route, APIRoute):
|
|
184
|
-
route.operation_id = route.name
|
|
185
|
-
openapi_schema = get_openapi(
|
|
186
|
-
title=app.title,
|
|
187
|
-
version=app.version,
|
|
188
|
-
openapi_version=app.openapi_version,
|
|
189
|
-
description=app.description,
|
|
190
|
-
routes=app.routes,
|
|
191
|
-
)
|
|
192
|
-
app.openapi_schema = openapi_schema
|
|
193
|
-
return app.openapi_schema
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
app.openapi = custom_openapi # ty: ignore[invalid-assignment]
|