使用无服务器从 Swagger UI 隐藏 OPTIONS 端点
Hide OPTIONS endpoint from Swagger UI using serverless
我已经为无服务器 YAML 文件中的每个端点设置了 cors: true。但是,我不想在 swagger UI 中显示 "OPTIONS" 端点。我正在使用无服务器框架,下面是示例端点的代码:
sample name:
handler: path/to/the/handler/
events:
- http:
path: v1/sample
method: get
cors: true
private: true
documentation:
summary: "summary of the endpoint"
methodResponses:
- statusCode: "200"
responseBody:
description: "response body"
responseModels:
"application/json": "response model"
尽管启用了 CORS,但我希望 OPTIONS 在 Swagger UI 上不可见。
从技术上讲,OPTIONS
方法端点是 CORS 正常运行所必需的,因为它是 Preflight request 中使用的方法来检查 CORS 的可行性。
AWS Swagger 导出确实以相当侵入性的方式包含 OPTIONS
端点。如果你不想在你的 Swagger UI 中使用它,我建议你在将它用于 Swagger UI(取决于您构建 Swagger 的方式 UI)。
我已经为无服务器 YAML 文件中的每个端点设置了 cors: true。但是,我不想在 swagger UI 中显示 "OPTIONS" 端点。我正在使用无服务器框架,下面是示例端点的代码:
sample name:
handler: path/to/the/handler/
events:
- http:
path: v1/sample
method: get
cors: true
private: true
documentation:
summary: "summary of the endpoint"
methodResponses:
- statusCode: "200"
responseBody:
description: "response body"
responseModels:
"application/json": "response model"
尽管启用了 CORS,但我希望 OPTIONS 在 Swagger UI 上不可见。
从技术上讲,OPTIONS
方法端点是 CORS 正常运行所必需的,因为它是 Preflight request 中使用的方法来检查 CORS 的可行性。
AWS Swagger 导出确实以相当侵入性的方式包含 OPTIONS
端点。如果你不想在你的 Swagger UI 中使用它,我建议你在将它用于 Swagger UI(取决于您构建 Swagger 的方式 UI)。