Skip to content

Commit

Permalink
Merge pull request #844 from fantapop/fix-843-make-oauth-flow-type-le…
Browse files Browse the repository at this point in the history
…ss-strict

fix: make flows optional in OauthFlow security schemas
  • Loading branch information
WoH committed Nov 16, 2020
2 parents 5de342b + e68e46d commit d5e58e3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/runtime/src/swagger/swagger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ export namespace Swagger {
}

export type OAuthFlow = {
[flowName in OAuth2FlowTypes]: OAuth2SecurityFlow3;
[flowName in OAuth2FlowTypes]?: OAuth2SecurityFlow3;
};
export type OAuth2FlowTypes = 'authorizationCode' | 'implicit' | 'password' | 'clientCredentials';
export type Security = BasicSecurity | BasicSecurity3 | ApiKeySecurity | OAuth2AccessCodeSecurity | OAuth2ApplicationSecurity | OAuth2ImplicitSecurity | OAuth2PasswordSecurity | OAuth2Security3;
Expand Down
16 changes: 16 additions & 0 deletions tests/unit/swagger/schemaDetails3.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ describe('Definition generation for OpenAPI 3.0.0', () => {

const flow = password.flows.password;

if (!flow) {
throw new Error('No password flow.');
}

expect(flow.tokenUrl).to.equal('/ats-api/auth/token');
expect(flow.authorizationUrl).to.be.undefined;

Expand All @@ -165,6 +169,10 @@ describe('Definition generation for OpenAPI 3.0.0', () => {

const flow = app.flows.clientCredentials;

if (!flow) {
throw new Error('No clientCredentials flow.');
}

expect(flow.tokenUrl).to.equal('/ats-api/auth/token');
expect(flow.authorizationUrl).to.be.undefined;

Expand All @@ -189,6 +197,10 @@ describe('Definition generation for OpenAPI 3.0.0', () => {

const flow = authCode.flows.authorizationCode;

if (!flow) {
throw new Error('No authorizationCode flow.');
}

expect(flow.tokenUrl).to.equal('/ats-api/auth/token');
expect(flow.authorizationUrl).to.equal('/ats-api/auth/authorization');

Expand All @@ -213,6 +225,10 @@ describe('Definition generation for OpenAPI 3.0.0', () => {

const flow = imp.flows.implicit;

if (!flow) {
throw new Error('No implicit flow.');
}

expect(flow.tokenUrl).to.be.undefined;
expect(flow.authorizationUrl).to.equal('/ats-api/auth/authorization');

Expand Down

0 comments on commit d5e58e3

Please sign in to comment.