Skip to content

Commit dcf5984

Browse files
api-clients-generation-pipeline[bot]skarimoci.datadog-api-spec
authored
Add support for documenting auth bearer token (#1953)
* disable bearer auth * Regenerate client from commit 7a9d0200 of spec repo --------- Co-authored-by: Sherzod Karimov <[email protected]> Co-authored-by: api-clients-generation-pipeline[bot] <54105614+api-clients-generation-pipeline[bot]@users.noreply.github.com> Co-authored-by: ci.datadog-api-spec <[email protected]> Co-authored-by: skarimo <[email protected]>
1 parent 7cd8622 commit dcf5984

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

.apigentools-info

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"spec_versions": {
55
"v1": {
66
"apigentools_version": "1.6.6",
7-
"regenerated": "2024-12-10 21:05:03.532177",
8-
"spec_repo_commit": "1c4c91d4"
7+
"regenerated": "2024-12-11 14:25:01.122850",
8+
"spec_repo_commit": "7a9d0200"
99
},
1010
"v2": {
1111
"apigentools_version": "1.6.6",
12-
"regenerated": "2024-12-10 21:05:03.552937",
13-
"spec_repo_commit": "1c4c91d4"
12+
"regenerated": "2024-12-11 14:25:01.142270",
13+
"spec_repo_commit": "7a9d0200"
1414
}
1515
}
1616
}

.generator/schemas/v1/openapi.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23427,6 +23427,12 @@ components:
2342723427
type: apiKey
2342823428
x-auth-id-alias: appKeyAuth
2342923429
x-env-name: DD_APP_KEY
23430+
bearerAuth:
23431+
in: header
23432+
name: Authorization
23433+
scheme: bearer
23434+
type: http
23435+
x-env-name: DD_BEARER_TOKEN
2343023436
info:
2343123437
contact:
2343223438

.generator/schemas/v2/openapi.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27751,6 +27751,12 @@ components:
2775127751
name: DD-APPLICATION-KEY
2775227752
type: apiKey
2775327753
x-env-name: DD_APP_KEY
27754+
bearerAuth:
27755+
in: header
27756+
name: Authorization
27757+
scheme: bearer
27758+
type: http
27759+
x-env-name: DD_BEARER_TOKEN
2775427760
info:
2775527761
contact:
2775627762

.generator/src/generator/templates/auth/auth.j2

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface TokenProvider {
2121
getToken(): Promise<string> | string;
2222
}
2323

24-
{%- for name, schema in openapi.components.securitySchemes.items() %}
24+
{%- for name, schema in openapi.components.securitySchemes.items() if schema.scheme != "bearer" %}
2525

2626
/**
2727
* Applies {{ schema.type }} authentication to the request context.
@@ -88,7 +88,7 @@ export class {{ name|camel_case }}Authentication implements SecurityAuthenticati
8888
{%- endfor %}
8989

9090
export type AuthMethods = {
91-
{%- for name, schema in openapi.components.securitySchemes.items() %}
91+
{%- for name, schema in openapi.components.securitySchemes.items() if schema.scheme != "bearer" %}
9292
"{{ name }}"?: SecurityAuthentication{%- if loop.nextitem %},{%- endif %}
9393
{%- endfor %}
9494
}
@@ -99,7 +99,7 @@ export type HttpBearerConfiguration = { tokenProvider: TokenProvider };
9999
export type OAuth2Configuration = { accessToken: string };
100100

101101
export type AuthMethodsConfiguration = {
102-
{%- for name, schema in openapi.components.securitySchemes.items() %}
102+
{%- for name, schema in openapi.components.securitySchemes.items() if schema.scheme != "bearer" %}
103103
"{{ name }}"?: {% if schema.type == "apiKey" %}ApiKeyConfiguration{%-endif %}{% if schema.type == "basic" %}HttpBasicConfiguration{%- endif %}{% if schema.type == "bearer" %}HttpBearerConfiguration{%- endif %}{% if schema.type == "oauth2" %}OAuth2Configuration{%- endif %}{%- if loop.nextitem %},{%- endif %}
104104
{%- endfor %}
105105
}
@@ -115,7 +115,7 @@ export function configureAuthMethods(config: AuthMethodsConfiguration | undefine
115115
return authMethods;
116116
}
117117

118-
{%- for name, schema in openapi.components.securitySchemes.items() %}
118+
{%- for name, schema in openapi.components.securitySchemes.items() if schema.scheme != "bearer" %}
119119

120120
if (config["{{ name }}"]) {
121121
authMethods["{{ name }}"] = new {{ name|camel_case }}Authentication(

0 commit comments

Comments
 (0)