Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookie apiKey sent as header #4355

Closed
rcollette opened this issue Mar 21, 2018 · 3 comments
Closed

Cookie apiKey sent as header #4355

rcollette opened this issue Mar 21, 2018 · 3 comments
Assignees

Comments

@rcollette
Copy link

{"swaggerUi":{"version":"3.12.0","gitRevision":"g83232dc","gitDirty":true,"buildTimestamp":"Sat, 03 Mar 2018 05:22:05 GMT","machine":"travis-job-a5ffded3-9cf0-48f8-b99a-15fd3e9e1aed"}}

Bug
Swashbuckle 2.3.0
Chrome Version 65.0.3325.162 (Official Build) (64-bit)
OSx

Demonstration API definition

{
  "swagger":"2.0",
  "info":{
    "title":"SendPro Locations",
    "contact":{
      "name":"Richard Collette"
    }
  },
  "paths":{
    "/Info":{
      "get":{
        "tags":[
          "Info"
        ],
        "summary":"Returns application identity and version information.",
        "operationId":"InfoGet",
        "consumes":[

        ],
        "produces":[
          "application/json"
        ],
        "responses":{
          "200":{
            "description":"Application version information.",
            "schema":{
              "$ref":"#/definitions/ApplicationInfo"
            }
          }
        }
      }
    },
    "/api/v1/Locations":{
      "get":{
        "tags":[
          "Locations"
        ],
        "summary":"Get a page of locations for the current user's subscription",
        "operationId":"ApiV1LocationsGet",
        "consumes":[

        ],
        "produces":[
          "application/json"
        ],
        "parameters":[
          {
            "name":"pageNumber",
            "in":"query",
            "description":"The pageNumber, 1 based",
            "required":true,
            "type":"integer",
            "format":"int32"
          },
          {
            "name":"pageSize",
            "in":"query",
            "description":"The number of locations to include in the page.",
            "required":true,
            "type":"integer",
            "format":"int32"
          }
        ],
        "responses":{
          "200":{
            "description":"The paged set of Locations",
            "schema":{
              "$ref":"#/definitions/PagedList[LocationDto]"
            }
          },
          "401":{
            "description":"Unauthorized"
          },
          "403":{
            "description":"Forbidden"
          }
        },
        "security":[
          {
            "authToken":[
              null
            ]
          }
        ]
      },
      "post":{
        "tags":[
          "Locations"
        ],
        "summary":"Creates a new location for the current user's subscription",
        "description":"<para>Only one location may be specified as the default location.  When creating or updating a location, if its isDefault property is true,\r\n            it will become the one and only default location.</para>\r\n<para> TODO - This needs to be restricted by permission </para>",
        "operationId":"ApiV1LocationsPost",
        "consumes":[
          "application/json-patch+json",
          "application/json",
          "text/json",
          "application/*+json"
        ],
        "produces":[
          "application/json"
        ],
        "parameters":[
          {
            "name":"location",
            "in":"body",
            "description":"",
            "required":false,
            "schema":{
              "$ref":"#/definitions/Location"
            }
          }
        ],
        "responses":{
          "201":{
            "description":"Returns the created location which includes its assigned Id.",
            "schema":{
              "$ref":"#/definitions/LocationDto"
            }
          },
          "400":{
            "description":"Missing location, subscription id mismatch between URL and body, or location.Id &gt; 0"
          },
          "401":{
            "description":"Unauthorized"
          },
          "403":{
            "description":"Forbidden"
          }
        },
        "security":[
          {
            "authToken":[
              null
            ]
          }
        ]
      }
    },
    "/api/v1/Locations/IdNames":{
      "get":{
        "tags":[
          "Locations"
        ],
        "summary":"Get a list of location names and their id's for the user's subscription",
        "operationId":"ApiV1LocationsIdNamesGet",
        "consumes":[

        ],
        "produces":[
          "application/json"
        ],
        "parameters":[
          {
            "name":"limit",
            "in":"query",
            "description":"The maximum number of records to return",
            "required":true,
            "type":"integer",
            "format":"int32"
          }
        ],
        "responses":{
          "200":{
            "description":"An array of Id/LocationName pair values",
            "schema":{
              "type":"array",
              "items":{
                "$ref":"#/definitions/LocationIdNameDto"
              }
            }
          },
          "401":{
            "description":"Unauthorized"
          },
          "403":{
            "description":"Forbidden"
          }
        },
        "security":[
          {
            "authToken":[
              null
            ]
          }
        ]
      }
    },
    "/api/v1/Locations/{locationId}":{
      "get":{
        "tags":[
          "Locations"
        ],
        "summary":"Get a location by its locationId for the current user's subscription",
        "operationId":"ApiV1LocationsByLocationIdGet",
        "consumes":[

        ],
        "produces":[
          "application/json"
        ],
        "parameters":[
          {
            "name":"locationId",
            "in":"path",
            "description":"",
            "required":true,
            "type":"integer",
            "format":"int64"
          }
        ],
        "responses":{
          "200":{
            "description":"The location",
            "schema":{
              "$ref":"#/definitions/LocationDto"
            }
          },
          "404":{
            "description":"The location was not found."
          },
          "401":{
            "description":"Unauthorized"
          },
          "403":{
            "description":"Forbidden"
          }
        },
        "security":[
          {
            "authToken":[
              null
            ]
          }
        ]
      },
      "put":{
        "tags":[
          "Locations"
        ],
        "summary":"Updates an existing location",
        "description":"<para>Only one location may be specified as the default location.  When creating or updating a location, if its isDefault property is true,\r\n            it will become the one and only default location.</para>",
        "operationId":"ApiV1LocationsByLocationIdPut",
        "consumes":[
          "application/json-patch+json",
          "application/json",
          "text/json",
          "application/*+json"
        ],
        "produces":[
          "application/json"
        ],
        "parameters":[
          {
            "name":"locationId",
            "in":"path",
            "description":"",
            "required":true,
            "type":"integer",
            "format":"int64"
          },
          {
            "name":"location",
            "in":"body",
            "description":"",
            "required":false,
            "schema":{
              "$ref":"#/definitions/Location"
            }
          }
        ],
        "responses":{
          "200":{
            "description":"Returns the updated location.",
            "schema":{
              "$ref":"#/definitions/LocationDto"
            }
          },
          "404":{
            "description":"The location to update was not found."
          },
          "401":{
            "description":"Unauthorized"
          },
          "403":{
            "description":"Forbidden"
          }
        },
        "security":[
          {
            "authToken":[
              null
            ]
          }
        ]
      }
    },
    "/api/v1/Locations/default":{
      "get":{
        "tags":[
          "Locations"
        ],
        "summary":"Gets the default location for the current user's subscription",
        "operationId":"ApiV1LocationsDefaultGet",
        "consumes":[

        ],
        "produces":[
          "application/json"
        ],
        "responses":{
          "200":{
            "description":"Returns the default location",
            "schema":{
              "$ref":"#/definitions/LocationDto"
            }
          },
          "404":{
            "description":"No default location exists for the provided subscription id."
          },
          "401":{
            "description":"Unauthorized"
          },
          "403":{
            "description":"Forbidden"
          }
        },
        "security":[
          {
            "authToken":[
              null
            ]
          }
        ]
      }
    },
    "/api/v1/Locations/assigned-location":{
      "get":{
        "tags":[
          "Locations"
        ],
        "summary":"Gets the location associated with the current user or the default location if it exists.",
        "description":"Some remarks",
        "operationId":"ApiV1LocationsAssigned-locationGet",
        "consumes":[

        ],
        "produces":[
          "application/json"
        ],
        "responses":{
          "200":{
            "description":"Returns the location",
            "schema":{
              "$ref":"#/definitions/LocationDto"
            }
          },
          "404":{
            "description":"If the user is not associated with a location and there is no default location"
          },
          "401":{
            "description":"Unauthorized"
          },
          "403":{
            "description":"Forbidden"
          }
        },
        "security":[
          {
            "authToken":[
              null
            ]
          }
        ]
      }
    }
  },
  "definitions":{
    "ApplicationInfo":{
      "type":"object",
      "properties":{
        "environmentName":{
          "type":"string"
        },
        "applicationName":{
          "type":"string"
        },
        "version":{
          "type":"string"
        }
      }
    },
    "PagedList[LocationDto]":{
      "type":"object",
      "properties":{
        "pageNumber":{
          "format":"int32",
          "type":"integer",
          "readOnly":true
        },
        "pageSize":{
          "format":"int32",
          "type":"integer",
          "readOnly":true
        },
        "hasNextPage":{
          "type":"boolean",
          "readOnly":true
        },
        "items":{
          "type":"array",
          "items":{
            "$ref":"#/definitions/LocationDto"
          },
          "readOnly":true
        }
      }
    },
    "LocationDto":{
      "type":"object",
      "properties":{
        "id":{
          "format":"int64",
          "type":"integer"
        },
        "locationName":{
          "type":"string"
        },
        "contactFullName":{
          "type":"string"
        },
        "companyName":{
          "type":"string"
        },
        "address":{
          "$ref":"#/definitions/Address"
        },
        "phoneNumber":{
          "type":"string"
        },
        "locationState":{
          "enum":[
            "inactive",
            "active"
          ],
          "type":"string"
        },
        "isDefault":{
          "type":"boolean"
        }
      }
    },
    "Address":{
      "required":[
        "streetLine1",
        "city",
        "state",
        "postalCode",
        "isoCountryCode2"
      ],
      "type":"object",
      "properties":{
        "streetLine1":{
          "maxLength":50,
          "type":"string"
        },
        "streetLine2":{
          "maxLength":50,
          "type":"string"
        },
        "streetLine3":{
          "maxLength":50,
          "type":"string"
        },
        "streetLine4":{
          "maxLength":50,
          "type":"string"
        },
        "city":{
          "maxLength":28,
          "type":"string"
        },
        "state":{
          "maxLength":2,
          "type":"string"
        },
        "postalCode":{
          "maxLength":10,
          "type":"string"
        },
        "isoCountryCode2":{
          "maxLength":2,
          "type":"string"
        }
      }
    },
    "Location":{
      "required":[
        "subscriptionId",
        "locationState"
      ],
      "type":"object",
      "properties":{
        "id":{
          "format":"int64",
          "type":"integer"
        },
        "locationName":{
          "maxLength":100,
          "type":"string"
        },
        "contactFullName":{
          "maxLength":255,
          "type":"string"
        },
        "companyName":{
          "maxLength":50,
          "type":"string"
        },
        "address":{
          "$ref":"#/definitions/Address"
        },
        "phoneNumber":{
          "maxLength":25,
          "type":"string"
        },
        "subscriptionId":{
          "maxLength":255,
          "type":"string"
        },
        "locationState":{
          "enum":[
            "inactive",
            "active"
          ],
          "type":"string"
        },
        "uspsPostageAccountNumber":{
          "maxLength":15,
          "type":"string"
        },
        "isDefault":{
          "type":"boolean"
        },
        "createdDate":{
          "format":"date-time",
          "type":"string",
          "readOnly":true
        },
        "modifiedDate":{
          "format":"date-time",
          "type":"string",
          "readOnly":true
        }
      }
    },
    "LocationIdNameDto":{
      "type":"object",
      "properties":{
        "locationName":{
          "type":"string"
        },
        "id":{
          "format":"int64",
          "type":"integer"
        }
      }
    },
    "PagedList[Location]":{
      "type":"object",
      "properties":{
        "pageNumber":{
          "format":"int32",
          "type":"integer",
          "readOnly":true
        },
        "pageSize":{
          "format":"int32",
          "type":"integer",
          "readOnly":true
        },
        "hasNextPage":{
          "type":"boolean",
          "readOnly":true
        },
        "items":{
          "type":"array",
          "items":{
            "$ref":"#/definitions/Location"
          },
          "readOnly":true
        }
      }
    }
  },
  "securityDefinitions":{
    "authToken":{
      "name":"authToken",
      "in":"cookie",
      "type":"apiKey",
      "description":"JWT authorization token sent in the authToken cookie."
    }
  }
}

Expected Behavior

Should send in a cookie header

Current Behavior

Sent as a plain header

curl -X GET "http://host/api/v1/Locations?pageNumber=1&pageSize=10" -H "accept: application/json" -H "authToken: theAuthToken"

Context

Not able to use "try it" functionality.

@hkosova
Copy link
Contributor

hkosova commented Mar 22, 2018

OpenAPI 2.0 only supports API keys in: header and in: query. If you post your definition into http://editor.swagger.io, you'll see a syntax error about that. Your API definition also has other syntax errors, btw.

API keys sent in: cookie are supported in OpenAPI 3.0 - but currently not supported in Swagger UI. This is being traked in swagger-api/swagger-js#1163.

@rcollette
Copy link
Author

Thank you. I wasn't aware of the editor. Good to know

@lock
Copy link

lock bot commented Jul 2, 2019

Locking due to inactivity.

This is done to avoid resurrecting old issues and bumping long threads with new, possibly unrelated content.

If you think you're experiencing something similar to what you've found here: please open a new issue, follow the template, and reference this issue in your report.

Thanks!

@lock lock bot locked and limited conversation to collaborators Jul 2, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants