diff --git a/example/swagger-files/auth-types.json b/example/swagger-files/auth-types.json index 2406746f4..b4482ac22 100644 --- a/example/swagger-files/auth-types.json +++ b/example/swagger-files/auth-types.json @@ -69,6 +69,21 @@ } ] } + }, + "/anything/apiKey-cookie": { + "post": { + "summary": "ApiKey security type via cookie", + "responses": { + "200": { + "description": "OK" + } + }, + "security": [ + { + "apiKeyCookie": [] + } + ] + } } }, "components": { @@ -89,10 +104,15 @@ "type": "apiKey", "in": "query", "name": "apiKey" + }, + "apiKeyCookie": { + "type": "apiKey", + "in": "cookie", + "name": "apiKey" } } }, "x-explorer-enabled": true, "x-samples-enabled": true, - "x-samples-languages": ["curl", "node", "ruby", "javascript", "python"] + "x-samples-languages": ["curl", "node", "node-simple", "ruby", "javascript", "python"] } diff --git a/packages/api-explorer/package-lock.json b/packages/api-explorer/package-lock.json index e4f31a86d..708de4b1c 100644 --- a/packages/api-explorer/package-lock.json +++ b/packages/api-explorer/package-lock.json @@ -1542,9 +1542,9 @@ } }, "@readme/oas-tooling": { - "version": "3.4.7", - "resolved": "https://registry.npmjs.org/@readme/oas-tooling/-/oas-tooling-3.4.7.tgz", - "integrity": "sha512-Pn3AUo5qJSbjOdVzbuOsQ2ZX5UmZ9wS5Iwf08x6tTpUNKuPh93WJtCUZbndoFv1pIZjzrHWJYdTTaXcwnhj3jg==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@readme/oas-tooling/-/oas-tooling-3.5.0.tgz", + "integrity": "sha512-5HSj/2L2Kpn7+3SUOCh8s826EDXeHDv1AmqeCb7udKfQ4RHCXFB9zQzcERIVISt38D+iidv8l3WBJaj9g1nEYA==", "requires": { "jsonpointer": "^4.0.1", "path-to-regexp": "^6.1.0" diff --git a/packages/api-explorer/package.json b/packages/api-explorer/package.json index a117017f1..34cf23dde 100644 --- a/packages/api-explorer/package.json +++ b/packages/api-explorer/package.json @@ -9,7 +9,7 @@ "@readme/markdown-magic": "^6.12.0", "@readme/oas-extensions": "^6.10.2", "@readme/oas-to-har": "^6.12.1", - "@readme/oas-tooling": "^3.4.7", + "@readme/oas-tooling": "^3.5.0", "@readme/react-jsonschema-form": "^1.1.5", "@readme/syntax-highlighter": "^6.10.2", "@readme/variable": "^6.10.2", diff --git a/packages/oas-to-har/__tests__/index.test.js b/packages/oas-to-har/__tests__/index.test.js index 2aadfb381..d181f4beb 100644 --- a/packages/oas-to-har/__tests__/index.test.js +++ b/packages/oas-to-har/__tests__/index.test.js @@ -1171,6 +1171,38 @@ describe('auth', () => { ]); }); + it('should work for cookie', () => { + expect( + oasToHar( + new Oas({ + components: { + securitySchemes: { + 'auth-cookie': { + type: 'apiKey', + name: 'authCookie', + in: 'cookie', + }, + }, + }, + }), + { + path: '/security', + method: 'get', + security: [{ 'auth-cookie': [] }], + }, + {}, + { + 'auth-cookie': 'value', + } + ).log.entries[0].request.cookies + ).toStrictEqual([ + { + name: 'authCookie', + value: 'value', + }, + ]); + }); + it('should work for multiple (||)', () => { expect( oasToHar( diff --git a/packages/oas-to-har/package-lock.json b/packages/oas-to-har/package-lock.json index 1582d5161..d4e48f665 100644 --- a/packages/oas-to-har/package-lock.json +++ b/packages/oas-to-har/package-lock.json @@ -1023,9 +1023,9 @@ "integrity": "sha512-+M68oHORq/jA9DuJfMPySg8/iitpitQLd/SC+Zr5ADspK3lArBfXRXPkEyhRKI8peAFexXK2MeSag+WbMt70+Q==" }, "@readme/oas-tooling": { - "version": "3.4.7", - "resolved": "https://registry.npmjs.org/@readme/oas-tooling/-/oas-tooling-3.4.7.tgz", - "integrity": "sha512-Pn3AUo5qJSbjOdVzbuOsQ2ZX5UmZ9wS5Iwf08x6tTpUNKuPh93WJtCUZbndoFv1pIZjzrHWJYdTTaXcwnhj3jg==", + "version": "3.5.0", + "resolved": "https://registry.npmjs.org/@readme/oas-tooling/-/oas-tooling-3.5.0.tgz", + "integrity": "sha512-5HSj/2L2Kpn7+3SUOCh8s826EDXeHDv1AmqeCb7udKfQ4RHCXFB9zQzcERIVISt38D+iidv8l3WBJaj9g1nEYA==", "requires": { "jsonpointer": "^4.0.1", "path-to-regexp": "^6.1.0" diff --git a/packages/oas-to-har/package.json b/packages/oas-to-har/package.json index 396835366..14befef29 100644 --- a/packages/oas-to-har/package.json +++ b/packages/oas-to-har/package.json @@ -5,7 +5,7 @@ "main": "src/index.js", "dependencies": { "@readme/oas-extensions": "^6.10.2", - "@readme/oas-tooling": "^3.4.7" + "@readme/oas-tooling": "^3.5.0" }, "scripts": { "inspect": "jsinspect", diff --git a/packages/oas-to-har/src/lib/configure-security.js b/packages/oas-to-har/src/lib/configure-security.js index d83a3e313..05e0be8dc 100644 --- a/packages/oas-to-har/src/lib/configure-security.js +++ b/packages/oas-to-har/src/lib/configure-security.js @@ -50,6 +50,11 @@ module.exports = function configureSecurity(oas, values, scheme) { } return harValue('headers', header); + } else if (security.in === 'cookie') { + return harValue('cookies', { + name: security.name, + value: values[scheme], + }); } }