Skip to content

When using Try It Out with Open API 3, multiple cookie apiKeys are separated with & not ; as required by curl #4218

Open
@absurdist

Description

@absurdist

When multiple API keys are specified in the security object, Try it Out separates the name value pairs with an ampersand. Curl expects a semi colon and the request will fail

_I'm attempting to locate the source of the error, am new to react and the code base, any guidance would be appreciated.
looks like the problem will be in the creation of the request headers prior to calling the curl formatting function in swagger-ui/src/core/curlify.js

But I'm still at the stage of fumbling around trying to orient myself in the code._

Q A
Bug or feature request? BUG
Which Swagger/OpenAPI version? 3
Which Swagger-UI version? "version":"3.9.3"
How did you install Swagger-UI? git clone, npm run-script build, ws
Which browser & version? Version 64.0.3282.140
Which operating system? windows 7

Demonstration API definition

openapi: 3.0.5
info:
  title: test api
  description: test api
  version: 1.0.0

paths:
  /tests:
    get:
      description: "test use of two api keys in cookie"
      operationId: testGet
      tags:
      - test

      responses:
        '200':
          description: test
          content:
            # application/json:
            #   schema:{}
            #     {
            #       "title": "test-response",
            #       "type": "object",
            #       "properties": {
            #           "value": "integer"
            #       }
            #   }



components:
  securitySchemes:
    keyA:
      type: apiKey
      in: cookie
      name: key-a

    keyB:
      type: apiKey
      in: cookie
      name: keyB

security:
  - keyA: []
    keyB: []

servers:
  - url: 'http://localhost'
    description: localhost

Expected Behavior

Try it out should create a call like this:

    curl -X GET "http://localhost/tests" -H "accept: */*" -H "Cookie: key-a=a; keyB=b"

or

    curl -X GET "http://localhost/tests" -H "accept: */*" -b "key-a=a; keyB=b"

see:
http://www.mit.edu/afs.new/sipb/user/ssen/src/curl-7.11.1/docs/curl.html

Current Behavior

Try it out produces this:

    curl -X GET "http://localhost/tests" -H "accept: */*" -H "Cookie: key-a=a&keyB=b"

Context

This issue is preventing me from using swagger to demonstrate a new API over a system with a legacy security model that requires multiple cookie values to be passed

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions