fix: 修复 OpenAPI 方法名大小写解析问题,添加建表 SQL

This commit is contained in:
2026-05-23 18:40:27 +08:00
parent 89fbc6437a
commit 128e163688
2 changed files with 37 additions and 2 deletions
+34
View File
@@ -0,0 +1,34 @@
CREATE TABLE IF NOT EXISTS emotion_museum.api_endpoint (
id VARCHAR(64) PRIMARY KEY,
path VARCHAR(500) NOT NULL,
method VARCHAR(10) NOT NULL,
operation_id VARCHAR(200),
summary VARCHAR(500),
description TEXT,
tags VARCHAR(500),
deprecated TINYINT(1) DEFAULT 0,
request_schema JSON,
response_schema JSON,
create_by VARCHAR(64),
create_time DATETIME DEFAULT CURRENT_TIMESTAMP,
update_by VARCHAR(64),
update_time DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
is_deleted TINYINT(1) DEFAULT 0,
remarks VARCHAR(500),
UNIQUE INDEX idx_operation_id (operation_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
CREATE TABLE IF NOT EXISTS emotion_museum.api_param (
id VARCHAR(64) PRIMARY KEY,
endpoint_id VARCHAR(64) NOT NULL,
param_type VARCHAR(20) NOT NULL,
name VARCHAR(100) NOT NULL,
required TINYINT(1) DEFAULT 0,
param_type_def VARCHAR(50),
description VARCHAR(500),
default_value VARCHAR(200),
enum_values JSON,
example VARCHAR(500),
INDEX idx_endpoint (endpoint_id),
FOREIGN KEY (endpoint_id) REFERENCES emotion_museum.api_endpoint(id) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;
@@ -137,11 +137,12 @@ public class ApiEndpointServiceImpl implements ApiEndpointService {
JsonNode methods = pathEntry.getValue(); JsonNode methods = pathEntry.getValue();
for (Iterator<String> it = methods.fieldNames(); it.hasNext(); ) { for (Iterator<String> it = methods.fieldNames(); it.hasNext(); ) {
String method = it.next().toUpperCase(); String methodKey = it.next();
String method = methodKey.toUpperCase();
// Skip non-HTTP-method keys (e.g., summary, description at path level) // Skip non-HTTP-method keys (e.g., summary, description at path level)
if (!isHttpMethod(method)) continue; if (!isHttpMethod(method)) continue;
JsonNode endpointNode = methods.get(method); JsonNode endpointNode = methods.get(methodKey);
String operationId = endpointNode.path("operationId").asText(); String operationId = endpointNode.path("operationId").asText();
if (operationId.isEmpty()) continue; if (operationId.isEmpty()) continue;