fork of hey-api/openapi-ts because I need some additional things

Merge pull request #1602 from hey-api/fix/oauth2-flows-sdk

fix: support all oauth2 flows in sdk auth

authored by

Lubos and committed by
GitHub
5164eb3f 1b73773e

+33 -40
+5
.changeset/rotten-rabbits-bow.md
··· 1 + --- 2 + '@hey-api/openapi-ts': patch 3 + --- 4 + 5 + fix: support all oauth2 flows in sdk auth
+6 -2
packages/openapi-ts/src/plugins/@hey-api/sdk/plugin.ts
··· 128 128 securitySchemeObject: IR.SecurityObject; 129 129 }): Auth | undefined => { 130 130 if (securitySchemeObject.type === 'oauth2') { 131 - // TODO: parser - handle more/multiple oauth2 flows 132 - if (securitySchemeObject.flows.password) { 131 + if ( 132 + securitySchemeObject.flows.password || 133 + securitySchemeObject.flows.authorizationCode || 134 + securitySchemeObject.flows.clientCredentials || 135 + securitySchemeObject.flows.implicit 136 + ) { 133 137 return { 134 138 scheme: 'bearer', 135 139 type: 'http',
+2 -2
packages/openapi-ts/test/3.1.x.test.ts
··· 522 522 }, 523 523 { 524 524 config: createConfig({ 525 - input: 'security-oauth2.json', 525 + input: 'security-oauth2.yaml', 526 526 output: 'security-oauth2', 527 527 plugins: [ 528 528 { ··· 535 535 }, 536 536 { 537 537 config: createConfig({ 538 - input: 'security-oauth2.json', 538 + input: 'security-oauth2.yaml', 539 539 output: 'security-false', 540 540 plugins: [ 541 541 {
-36
packages/openapi-ts/test/spec/3.1.x/security-oauth2.json
··· 1 - { 2 - "openapi": "3.1.1", 3 - "info": { 4 - "title": "OpenAPI 3.1.1 security oauth2 example", 5 - "version": "1" 6 - }, 7 - "paths": { 8 - "/foo": { 9 - "get": { 10 - "responses": { 11 - "200": { 12 - "description": "OK" 13 - } 14 - }, 15 - "security": [ 16 - { 17 - "foo": [] 18 - } 19 - ] 20 - } 21 - } 22 - }, 23 - "components": { 24 - "securitySchemes": { 25 - "foo": { 26 - "flows": { 27 - "password": { 28 - "scopes": {}, 29 - "tokenUrl": "/" 30 - } 31 - }, 32 - "type": "oauth2" 33 - } 34 - } 35 - } 36 - }
+20
packages/openapi-ts/test/spec/3.1.x/security-oauth2.yaml
··· 1 + openapi: 3.1.1 2 + info: 3 + title: OpenAPI 3.1.1 security oauth2 example 4 + version: '1' 5 + paths: 6 + /foo: 7 + get: 8 + responses: 9 + '200': 10 + description: OK 11 + security: 12 + - foo: [] 13 + components: 14 + securitySchemes: 15 + foo: 16 + flows: 17 + password: 18 + scopes: {} 19 + tokenUrl: '/' 20 + type: 'oauth2'