Skip to content

Commit 4bd109e

Browse files
committed
Merge branch 'httpntlm'
2 parents 3acd779 + e789d69 commit 4bd109e

File tree

9 files changed

+217
-182
lines changed

9 files changed

+217
-182
lines changed

src/templates/core/fetch/request.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ import { OpenAPI } from './OpenAPI';
5050
/**
5151
* Request using fetch client
5252
* @param options The request options from the the service
53-
* @result ApiResult
53+
* @returns ApiResult
5454
* @throws ApiError
5555
*/
5656
export async function request(options: ApiRequestOptions): Promise<ApiResult> {

src/templates/core/fetch/sendRequest.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ async function sendRequest(options: ApiRequestOptions, url: string): Promise<Res
44
headers: await getHeaders(options),
55
body: getRequestBody(options),
66
};
7+
if (OpenAPI.WITH_CREDENTIALS) {
8+
request.credentials = 'include';
9+
}
710
return await fetch(url, request);
811
}

src/templates/core/node/request.hbs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,11 @@ import { OpenAPI } from './OpenAPI';
5252

5353

5454
/**
55-
* Request using node-fetch client
56-
* @param options The request options from the the service
57-
* @result ApiResult
58-
* @throws ApiError
59-
*/
55+
* Request using node-fetch client
56+
* @param options The request options from the the service
57+
* @returns ApiResult
58+
* @throws ApiError
59+
*/
6060
export async function request(options: ApiRequestOptions): Promise<ApiResult> {
6161
const url = getUrl(options);
6262
const response = await sendRequest(options, url);

src/templates/core/node/sendRequest.hbs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,8 @@ async function sendRequest(options: ApiRequestOptions, url: string): Promise<Res
44
headers: await getHeaders(options),
55
body: getRequestBody(options),
66
};
7+
if (OpenAPI.WITH_CREDENTIALS) {
8+
request.credentials = 'include';
9+
}
710
return await fetch(url, request);
811
}

src/templates/core/request.hbs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
{{#equals @root.httpClient 'fetch'}}{{>fetch/request}}{{/equals}}
2-
{{#equals @root.httpClient 'xhr'}}{{>xhr/request}}{{/equals}}
3-
{{#equals @root.httpClient 'node'}}{{>node/request}}{{/equals}}
1+
{{~#equals @root.httpClient 'fetch'}}{{>fetch/request}}{{/equals~}}
2+
{{~#equals @root.httpClient 'xhr'}}{{>xhr/request}}{{/equals~}}
3+
{{~#equals @root.httpClient 'node'}}{{>node/request}}{{/equals~}}

src/templates/core/xhr/request.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ import { OpenAPI } from './OpenAPI';
5353
/**
5454
* Request using XHR client
5555
* @param options The request options from the the service
56-
* @result ApiResult
56+
* @returns ApiResult
5757
* @throws ApiError
5858
*/
5959
export async function request(options: ApiRequestOptions): Promise<ApiResult> {

src/templates/exportService.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class {{{name}}} {
3131
{{/if}}
3232
{{/unless}}
3333
{{#each results}}
34-
* @result {{{type}}} {{{description}}}
34+
* @returns {{{type}}} {{{description}}}
3535
{{/each}}
3636
* @throws ApiError
3737
*/

test/__snapshots__/index.spec.js.snap

Lines changed: 37 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,9 @@ async function sendRequest(options: ApiRequestOptions, url: string): Promise<Res
208208
headers: await getHeaders(options),
209209
body: getRequestBody(options),
210210
};
211+
if (OpenAPI.WITH_CREDENTIALS) {
212+
request.credentials = 'include';
213+
}
211214
return await fetch(url, request);
212215
}
213216

@@ -263,7 +266,7 @@ function catchErrors(options: ApiRequestOptions, result: ApiResult): void {
263266
/**
264267
* Request using fetch client
265268
* @param options The request options from the the service
266-
* @result ApiResult
269+
* @returns ApiResult
267270
* @throws ApiError
268271
*/
269272
export async function request(options: ApiRequestOptions): Promise<ApiResult> {
@@ -282,9 +285,7 @@ export async function request(options: ApiRequestOptions): Promise<ApiResult> {
282285

283286
catchErrors(options, result);
284287
return result;
285-
}
286-
287-
"
288+
}"
288289
`;
289290

290291
exports[`v2 should generate: ./test/generated/v2/index.ts 1`] = `
@@ -1730,7 +1731,7 @@ export class ComplexService {
17301731
/**
17311732
* @param parameterObject Parameter containing object
17321733
* @param parameterReference Parameter containing reference
1733-
* @result ModelWithString Successful response
1734+
* @returns ModelWithString Successful response
17341735
* @throws ApiError
17351736
*/
17361737
public static async complexTypes(
@@ -1934,7 +1935,7 @@ import { OpenAPI } from '../core/OpenAPI';
19341935
export class HeaderService {
19351936

19361937
/**
1937-
* @result string Successful response
1938+
* @returns string Successful response
19381939
* @throws ApiError
19391940
*/
19401941
public static async callWithResultFromHeader(): Promise<string> {
@@ -2046,7 +2047,7 @@ import { OpenAPI } from '../core/OpenAPI';
20462047
export class ResponseService {
20472048

20482049
/**
2049-
* @result ModelWithString Message for default response
2050+
* @returns ModelWithString Message for default response
20502051
* @throws ApiError
20512052
*/
20522053
public static async callWithResponse(): Promise<ModelWithString> {
@@ -2058,7 +2059,7 @@ export class ResponseService {
20582059
}
20592060

20602061
/**
2061-
* @result ModelWithString Message for default response
2062+
* @returns ModelWithString Message for default response
20622063
* @throws ApiError
20632064
*/
20642065
public static async callWithDuplicateResponses(): Promise<ModelWithString> {
@@ -2075,10 +2076,10 @@ export class ResponseService {
20752076
}
20762077

20772078
/**
2078-
* @result any Message for 200 response
2079-
* @result ModelWithString Message for default response
2080-
* @result ModelThatExtends Message for 201 response
2081-
* @result ModelThatExtendsExtends Message for 202 response
2079+
* @returns any Message for 200 response
2080+
* @returns ModelWithString Message for default response
2081+
* @returns ModelThatExtends Message for 201 response
2082+
* @returns ModelThatExtendsExtends Message for 202 response
20822083
* @throws ApiError
20832084
*/
20842085
public static async callWithResponses(): Promise<{
@@ -2208,10 +2209,10 @@ export class TypesService {
22082209
* @param parameterBoolean This is a boolean parameter
22092210
* @param parameterObject This is an object parameter
22102211
* @param id This is a number parameter
2211-
* @result number Response is a simple number
2212-
* @result string Response is a simple string
2213-
* @result boolean Response is a simple boolean
2214-
* @result any Response is a simple object
2212+
* @returns number Response is a simple number
2213+
* @returns string Response is a simple string
2214+
* @returns boolean Response is a simple boolean
2215+
* @returns any Response is a simple object
22152216
* @throws ApiError
22162217
*/
22172218
public static async types(
@@ -2451,6 +2452,9 @@ async function sendRequest(options: ApiRequestOptions, url: string): Promise<Res
24512452
headers: await getHeaders(options),
24522453
body: getRequestBody(options),
24532454
};
2455+
if (OpenAPI.WITH_CREDENTIALS) {
2456+
request.credentials = 'include';
2457+
}
24542458
return await fetch(url, request);
24552459
}
24562460

@@ -2506,7 +2510,7 @@ function catchErrors(options: ApiRequestOptions, result: ApiResult): void {
25062510
/**
25072511
* Request using fetch client
25082512
* @param options The request options from the the service
2509-
* @result ApiResult
2513+
* @returns ApiResult
25102514
* @throws ApiError
25112515
*/
25122516
export async function request(options: ApiRequestOptions): Promise<ApiResult> {
@@ -2525,9 +2529,7 @@ export async function request(options: ApiRequestOptions): Promise<ApiResult> {
25252529

25262530
catchErrors(options, result);
25272531
return result;
2528-
}
2529-
2530-
"
2532+
}"
25312533
`;
25322534

25332535
exports[`v3 should generate: ./test/generated/v3/index.ts 1`] = `
@@ -4244,7 +4246,7 @@ export class ComplexService {
42444246
/**
42454247
* @param parameterObject Parameter containing object
42464248
* @param parameterReference Parameter containing reference
4247-
* @result ModelWithString Successful response
4249+
* @returns ModelWithString Successful response
42484250
* @throws ApiError
42494251
*/
42504252
public static async complexTypes(
@@ -4275,7 +4277,7 @@ export class ComplexService {
42754277
/**
42764278
* @param id
42774279
* @param requestBody
4278-
* @result ModelWithString Success
4280+
* @returns ModelWithString Success
42794281
* @throws ApiError
42804282
*/
42814283
public static async complexParams(
@@ -4478,7 +4480,7 @@ import { OpenAPI } from '../core/OpenAPI';
44784480
export class HeaderService {
44794481

44804482
/**
4481-
* @result string Successful response
4483+
* @returns string Successful response
44824484
* @throws ApiError
44834485
*/
44844486
public static async callWithResultFromHeader(): Promise<string> {
@@ -4507,7 +4509,7 @@ import { OpenAPI } from '../core/OpenAPI';
45074509
export class MultipartService {
45084510

45094511
/**
4510-
* @result any OK
4512+
* @returns any OK
45114513
* @throws ApiError
45124514
*/
45134515
public static async multipartResponse(): Promise<{
@@ -4699,7 +4701,7 @@ import { OpenAPI } from '../core/OpenAPI';
46994701
export class ResponseService {
47004702

47014703
/**
4702-
* @result ModelWithString
4704+
* @returns ModelWithString
47034705
* @throws ApiError
47044706
*/
47054707
public static async callWithResponse(): Promise<ModelWithString> {
@@ -4711,7 +4713,7 @@ export class ResponseService {
47114713
}
47124714

47134715
/**
4714-
* @result ModelWithString Message for default response
4716+
* @returns ModelWithString Message for default response
47154717
* @throws ApiError
47164718
*/
47174719
public static async callWithDuplicateResponses(): Promise<ModelWithString> {
@@ -4728,10 +4730,10 @@ export class ResponseService {
47284730
}
47294731

47304732
/**
4731-
* @result any Message for 200 response
4732-
* @result ModelWithString Message for default response
4733-
* @result ModelThatExtends Message for 201 response
4734-
* @result ModelThatExtendsExtends Message for 202 response
4733+
* @returns any Message for 200 response
4734+
* @returns ModelWithString Message for default response
4735+
* @returns ModelThatExtends Message for 201 response
4736+
* @returns ModelThatExtendsExtends Message for 202 response
47354737
* @throws ApiError
47364738
*/
47374739
public static async callWithResponses(): Promise<{
@@ -4861,10 +4863,10 @@ export class TypesService {
48614863
* @param parameterString This is a string parameter
48624864
* @param parameterBoolean This is a boolean parameter
48634865
* @param id This is a number parameter
4864-
* @result number Response is a simple number
4865-
* @result string Response is a simple string
4866-
* @result boolean Response is a simple boolean
4867-
* @result any Response is a simple object
4866+
* @returns number Response is a simple number
4867+
* @returns string Response is a simple string
4868+
* @returns boolean Response is a simple boolean
4869+
* @returns any Response is a simple object
48684870
* @throws ApiError
48694871
*/
48704872
public static async types(
@@ -4907,7 +4909,7 @@ export class UploadService {
49074909

49084910
/**
49094911
* @param file Supply a file reference for upload
4910-
* @result boolean
4912+
* @returns boolean
49114913
* @throws ApiError
49124914
*/
49134915
public static async uploadFile(

0 commit comments

Comments
 (0)