Cookie authentication is supported in OpenAPI 3.0, but not in OpenAPI / Swagger 2.0.
In OpenAPI 3.0, cookie authentication is defined as an API key that is sent in: cookie :
openapi: 3.0.0 ... components: securitySchemes: cookieAuth: type: apiKey in: cookie name: COOKIE-NAME # replace with your cookie name paths: /showMySecretStuff: get: security: - cookieAuth: [] responses: '200': description: OK
The login operation is not related to securitySchemes any way, but you can define a Set-Cookie response header for documentation purposes:
paths: /login: post: requestBody: ... responses: '200': description: OK headers: Set-Cookie: description: > Contains the session cookie named `COOKIE-NAME`. Pass this cookie back in subsequent requests. schema: type: string
However, the Swagger editor and Swagger user interface do not currently support cookie authentication. Check out the OAS 3.0 Support Backlog for updates.
Helen source share