Reputation: 231
I have set cors: true for each endpoint in the serverless YAML file. However, I do not want to show "OPTIONS" endpoint in the swagger UI for the same. I am using the serverless framework and below is the code for sample endpoint:
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"
I am expecting that OPTIONS should NOT be visible on Swagger UI despite the CORS is enabled.
Upvotes: 3
Views: 1693
Reputation: 1948
Technically the OPTIONS
method endpoint is necessary for CORS to function correctly as it's the method used in the Preflight request that checks CORS viability.
AWS Swagger exports do include the OPTIONS
endpoint in quite an intrusive way. If you don't want it in your Swagger UI I suggest you programmatically filter the OPTIONS
endpoints out of the Swagger file after exporting it from API Gateway, before using it for Swagger UI (depending on how you construct your Swagger UI).
Upvotes: 2