2016-04-28 39 views
6

http://editor.swagger.io/でCookieベースの自動化を使用するAPIを文書化してテストしたいと思います。簡単な例を与える:次のYAMLを書く方法、/ loginアクションはCookieを作成し、Cookieは/ showMySecretStuffに渡されなければならないか?SwaggerエディタでCookiesを使用する方法

swagger: '2.0' 
info: 
    title: Test API 
    version: '1' 
host: my.test.com 
schemes: 
    - https 
basePath:/
consumes: 
    - multipart/form-data 
produces: 
    - application/json 
paths: 
    /login: 
    post: 
     parameters: 
     - name: username 
      in: formData 
      required: true 
      type: string 
     - name: password 
      in: formData 
      required: true 
      type: string 
      default: secret 
     responses: 
     200: 
      description: OK 
    /showMySecretStuff: 
    get: 
     responses: 
     200: 
      description: OK 

答えて

0

Cookie認証はOpenAPI 3.0ではサポートされていますが、OpenAPI/Swagger 2.0ではサポートされていません。 OpenAPIを3.0に

は、クッキー認証がin: cookie送信されたAPIキーのように定義されます。

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 

ログイン操作がどのような方法でsecuritySchemesにリンクされていないが、あなたはレスポンスヘッダを定義することもできますSet-Cookieつまり、Swagger EditorとSwagger UIは現在、Cookie認証をサポートしていません。更新についてはOAS 3.0 Support Backlogをご覧ください。

関連する問題