Skip to content

Commit

Permalink
Merge pull request #271 from konfig-dev/ENG-1225-1
Browse files Browse the repository at this point in the history
[ENG-1225] Make README changes for both SDKs + ergonomic updates to TypeScript SDK
  • Loading branch information
konfig-publisher authored Oct 11, 2023
2 parents 419337d + a15bcf6 commit ba6688b
Show file tree
Hide file tree
Showing 8 changed files with 42 additions and 16 deletions.
5 changes: 5 additions & 0 deletions generator/konfig-dash/.changeset/cold-carrots-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'konfig-lib': minor
---

support globally required security in TypeScript SDK
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ info:
version: 3.0.0
x-konfig-ignore:
object-with-no-properties: true
x-konfig-has-globally-required-security: true
servers:
- description: Production server
url: https://api.humanloop.com/v3
Expand Down Expand Up @@ -5351,6 +5352,7 @@ info:
email: [email protected]
x-konfig-ignore:
potential-incorrect-type: true
x-konfig-has-globally-required-security: true
servers:
- description: SnapTrade Production API
url: https://api.snaptrade.com/api/v1
Expand Down Expand Up @@ -15134,6 +15136,7 @@ info:
x-konfig-ignore:
object-with-no-properties: true
potential-incorrect-type: true
x-konfig-has-globally-required-security: true
x-konfig-uses-multipart-form-data: true
servers:
- url: https://in.staging.decentro.tech
Expand Down Expand Up @@ -22760,6 +22763,7 @@ info:
potential-incorrect-type: true
contact:
email: [email protected]
x-konfig-has-globally-required-security: true
x-konfig-uses-multipart-form-data: true
servers:
- url: https://in.staging.decentro.tech
Expand Down Expand Up @@ -30491,6 +30495,7 @@ info:
potential-incorrect-type: true
contact:
name: Decentro
x-konfig-has-globally-required-security: true
x-konfig-uses-multipart-form-data: true
servers:
- url: https://in.staging.decentro.tech
Expand Down Expand Up @@ -38222,6 +38227,7 @@ info:
potential-incorrect-type: true
contact:
url: https://decentro.tech
x-konfig-has-globally-required-security: true
x-konfig-uses-multipart-form-data: true
servers:
- url: https://in.staging.decentro.tech
Expand Down Expand Up @@ -46108,6 +46114,7 @@ info:
x-konfig-ignore:
object-with-no-properties: true
potential-incorrect-type: true
x-konfig-has-globally-required-security: true
servers:
- url: https://in.staging.decentro.tech
tags:
Expand Down Expand Up @@ -48216,6 +48223,7 @@ info:
version: 1.0.0
x-konfig-ignore:
potential-incorrect-type: true
x-konfig-has-globally-required-security: true
servers:
- url: https://api.nlite.ml/v1.0
tags:
Expand Down Expand Up @@ -102397,6 +102405,7 @@ info:
version: 3.0.0
x-konfig-ignore:
object-with-no-properties: true
x-konfig-has-globally-required-security: true
servers:
- description: Production server
url: https://api.humanloop.com/v3
Expand Down Expand Up @@ -107712,6 +107721,7 @@ info:
x-konfig-ignore:
object-with-no-properties: true
potential-incorrect-type: true
x-konfig-has-globally-required-security: true
x-konfig-uses-multipart-form-data: true
servers:
- url: https://in.staging.decentro.tech
Expand Down Expand Up @@ -115509,6 +115519,7 @@ info:
version: 3.0.0
x-konfig-ignore:
object-with-no-properties: true
x-konfig-has-globally-required-security: true
servers:
- description: Production server
url: https://api.humanloop.com/v3
Expand Down Expand Up @@ -120834,6 +120845,7 @@ info:
email: [email protected]
x-konfig-ignore:
potential-incorrect-type: true
x-konfig-has-globally-required-security: true
servers:
- description: SnapTrade Production API
url: https://api.snaptrade.com/api/v1
Expand Down Expand Up @@ -129590,6 +129602,7 @@ info:
x-konfig-ignore:
object-with-no-properties: true
potential-incorrect-type: true
x-konfig-has-globally-required-security: true
servers:
- url: https://in.staging.decentro.tech
tags:
Expand Down Expand Up @@ -131749,6 +131762,7 @@ info:
x-konfig-ignore:
object-with-no-properties: true
potential-incorrect-type: true
x-konfig-has-globally-required-security: true
x-konfig-uses-multipart-form-data: true
servers:
- url: https://in.staging.decentro.tech
Expand Down Expand Up @@ -139922,6 +139936,7 @@ info:
version: 3.0.0
x-konfig-ignore:
object-with-no-properties: true
x-konfig-has-globally-required-security: true
servers:
- description: Production server
url: https://api.humanloop.com/v3
Expand Down Expand Up @@ -145255,6 +145270,7 @@ info:
contact:
email: [email protected]
version: 1.0.1
x-konfig-has-globally-required-security: true
externalDocs:
description: Find out more about NewsCatcher
url: https://docs.newscatcherapi.com/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -359,10 +359,15 @@ export const transformSpec = async ({
return security in requirements
})
: false
const isRequired =
isGloballyRequired || securityCount[security] === operations.length
Object.assign(spec.spec.components.securitySchemes[security], {
'x-konfig-globally-required-security':
isGloballyRequired || securityCount[security] === operations.length,
'x-konfig-globally-required-security': isRequired,
})
if (isRequired)
Object.assign(spec.spec.info, {
'x-konfig-has-globally-required-security': isRequired,
})
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ const {{{clientNameLowercase}}} = new {{{clientName}}}({
{{{apiDocumentationAuthenticationPartial}}}
{{/apiDocumentationAuthenticationPartial}}
{{^apiDocumentationAuthenticationPartial}}
{{#includeFetchAdapter}}
// Use native Fetch API instead of axios
// useFetch: true,
{{/includeFetchAdapter}}
{{> api_doc_example_setup_parameters}}
{{/apiDocumentationAuthenticationPartial}}
})
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export class {{{clientName}}} extends {{{clientName}}}Custom {
readonly {{> apiClassName}}: {{classname}};
{{/apis}}

constructor(configurationParameters: ConfigurationParameters = {}) {
constructor(configurationParameters: ConfigurationParameters{{> configuration_default}}) {
super(configurationParameters);
const configuration = new Configuration(configurationParameters);
{{#apis}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export interface ConfigurationParameters {
{{> securityKeyName}}?: string;
{{/apiKeyMethods}}
{{/hasMultipleApiKeys}}
apiKey?: ApiKey;
{{> configuration_api_key}}
username?: string;
password?: string;
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
Expand Down Expand Up @@ -55,12 +55,7 @@ export class Configuration {
*/
{{{name}}}?: string;
{{/clientStateWithExamples}}
/**
* parameter for apiKey security
* @param name security name
* @memberof Configuration
*/
apiKey?: ApiKey;
{{> configuration_api_key}}
/**
* parameter for basic security
*
Expand Down Expand Up @@ -123,7 +118,7 @@ export class Configuration {
*/
userAgent: string;

constructor(param: ConfigurationParameters = {}) {
constructor(param: ConfigurationParameters{{> configuration_default}}) {
{{#clientState}}
this.{{{.}}} = param.{{{.}}}
{{/clientState}}
Expand All @@ -146,7 +141,7 @@ export class Configuration {
this.basePath = param.basePath;
this.baseOptions = param.baseOptions ?? {};
{{#includeFetchAdapter}}
if (param.useFetch) {
if (param.useFetch ?? true) {
this.baseOptions["adapter"] = fetchAdapter
}
{{/includeFetchAdapter}}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{{^hasMultipleApiKeys}}
{{#apiKeyMethods}}
/**
* parameter for apiKey security
* @param name security name
* @memberof Configuration
*/
apiKey{{^vendorExtensions.x-konfig-globally-required-security}}?{{/vendorExtensions.x-konfig-globally-required-security}}: ApiKey;{{/apiKeyMethods}}{{/hasMultipleApiKeys}}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{{^infoExtensions.x-konfig-has-globally-required-security}} = {}{{/infoExtensions.x-konfig-has-globally-required-security}}

0 comments on commit ba6688b

Please sign in to comment.