Skip to content

Commit 2a4b8f2

Browse files
committed
update samples after merge of master
1 parent 69ebc07 commit 2a4b8f2

11 files changed

Lines changed: 18 additions & 84 deletions

File tree

samples/client/echo_api/typescript-axios/build/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"prepare": "npm run build"
2323
},
2424
"dependencies": {
25-
"axios": "^1.13.5"
25+
"axios": "^1.6.1"
2626
},
2727
"devDependencies": {
2828
"@types/node": "12.11.5 - 12.20.42",

samples/client/petstore/java/feign-hc5/src/main/java/org/openapitools/client/ApiResponseDecoder.java

Lines changed: 5 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -18,99 +18,33 @@
1818
import feign.Types;
1919
import feign.jackson.JacksonDecoder;
2020

21-
import java.io.File;
2221
import java.io.IOException;
23-
import java.io.InputStream;
2422
import java.lang.reflect.ParameterizedType;
2523
import java.lang.reflect.Type;
26-
import java.nio.file.Files;
27-
import java.nio.file.Paths;
28-
import java.nio.file.StandardCopyOption;
2924
import java.util.Collection;
3025
import java.util.Collections;
3126
import java.util.Map;
32-
import java.util.regex.Matcher;
33-
import java.util.regex.Pattern;
3427

3528
import org.openapitools.client.model.ApiResponse;
3629

3730
public class ApiResponseDecoder extends JacksonDecoder {
3831

39-
private static final Pattern FILENAME_PATTERN =
40-
Pattern.compile("filename=\"([^\"]+)\"|filename=([^\\s;]+)");
41-
4232
public ApiResponseDecoder(ObjectMapper mapper) {
4333
super(mapper);
4434
}
4535

4636
@Override
4737
public Object decode(Response response, Type type) throws IOException {
38+
//Detects if the type is an instance of the parameterized class ApiResponse
4839
if (type instanceof ParameterizedType && Types.getRawType(type).isAssignableFrom(ApiResponse.class)) {
40+
//The ApiResponse class has a single type parameter, the Dto class itself
4941
Type responseBodyType = ((ParameterizedType) type).getActualTypeArguments()[0];
50-
Object body = isBinaryType(responseBodyType)
51-
? decodeBinary(response, responseBodyType)
52-
: super.decode(response, responseBodyType);
42+
Object body = super.decode(response, responseBodyType);
5343
Map<String, Collection<String>> responseHeaders = Collections.unmodifiableMap(response.headers());
5444
return new ApiResponse<>(response.status(), responseHeaders, body);
55-
}
56-
57-
if (isBinaryType(type)) {
58-
return decodeBinary(response, type);
59-
}
60-
61-
return super.decode(response, type);
62-
}
63-
64-
private boolean isBinaryType(Type type) {
65-
Class<?> raw = Types.getRawType(type);
66-
return File.class.isAssignableFrom(raw)
67-
|| byte[].class.isAssignableFrom(raw)
68-
|| InputStream.class.isAssignableFrom(raw);
69-
}
70-
71-
private Object decodeBinary(Response response, Type type) throws IOException {
72-
Class<?> raw = Types.getRawType(type);
73-
if (response.body() == null) {
74-
return null;
75-
}
76-
if (byte[].class.isAssignableFrom(raw)) {
77-
return response.body().asInputStream().readAllBytes();
78-
}
79-
if (InputStream.class.isAssignableFrom(raw)) {
80-
return response.body().asInputStream();
81-
}
82-
return downloadToTempFile(response);
83-
}
84-
85-
private File downloadToTempFile(Response response) throws IOException {
86-
String filename = extractFilename(response);
87-
File file;
88-
if (filename != null) {
89-
// Sanitize: strip path components to prevent path traversal
90-
String safeName = Paths.get(filename).getFileName().toString();
91-
java.nio.file.Path tempDir = Files.createTempDirectory("feign-download");
92-
file = Files.createFile(tempDir.resolve(safeName)).toFile();
93-
tempDir.toFile().deleteOnExit();
9445
} else {
95-
file = Files.createTempFile("download-", "").toFile();
96-
}
97-
file.deleteOnExit();
98-
try (InputStream is = response.body().asInputStream()) {
99-
Files.copy(is, file.toPath(), StandardCopyOption.REPLACE_EXISTING);
100-
}
101-
return file;
102-
}
103-
104-
private String extractFilename(Response response) {
105-
Collection<String> dispositions = response.headers().get("Content-Disposition");
106-
if (dispositions == null) return null;
107-
for (String disposition : dispositions) {
108-
Matcher m = FILENAME_PATTERN.matcher(disposition);
109-
if (m.find()) {
110-
// Group 1: quoted filename (may contain spaces), Group 2: unquoted token
111-
return m.group(1) != null ? m.group(1) : m.group(2);
112-
}
46+
//The response is not encapsulated in the ApiResponse, decode the Dto as normal
47+
return super.decode(response, type);
11348
}
114-
return null;
11549
}
11650
}

samples/client/petstore/typescript-axios/builds/es6-target/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"prepare": "npm run build"
2525
},
2626
"dependencies": {
27-
"axios": "^1.13.5"
27+
"axios": "^1.6.1"
2828
},
2929
"devDependencies": {
3030
"@types/node": "12.11.5 - 12.20.42",

samples/client/petstore/typescript-axios/builds/test-petstore/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -329,7 +329,7 @@ export type MammalAnyofTypeEnum = typeof MammalAnyofTypeEnum[keyof typeof Mammal
329329

330330
export interface MapTest {
331331
'map_map_of_string'?: { [key: string]: { [key: string]: string; }; };
332-
'map_of_enum_string'?: { [key: string]: MapTestMapOfEnumStringEnum; };
332+
'map_of_enum_string'?: { [key: string]: string; };
333333
'direct_map'?: { [key: string]: boolean; };
334334
'indirect_map'?: { [key: string]: boolean; };
335335
}

samples/client/petstore/typescript-axios/builds/with-complex-headers/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"prepare": "npm run build"
2323
},
2424
"dependencies": {
25-
"axios": "^1.13.5"
25+
"axios": "^1.6.1"
2626
},
2727
"devDependencies": {
2828
"@types/node": "12.11.5 - 12.20.42",

samples/client/petstore/typescript-axios/builds/with-fake-endpoints-models-for-testing-with-http-signature/api.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ export type Mammal = { className: 'whale' } & Whale | { className: 'zebra' } & Z
227227

228228
export interface MapTest {
229229
'map_map_of_string'?: { [key: string]: { [key: string]: string; }; };
230-
'map_of_enum_string'?: { [key: string]: MapTestMapOfEnumStringEnum; };
230+
'map_of_enum_string'?: { [key: string]: string; };
231231
'direct_map'?: { [key: string]: boolean; };
232232
'indirect_map'?: { [key: string]: boolean; };
233233
}

samples/client/petstore/typescript-axios/builds/with-npm-version-and-separate-models-and-api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"prepare": "npm run build"
2323
},
2424
"dependencies": {
25-
"axios": "^1.13.5"
25+
"axios": "^1.6.1"
2626
},
2727
"devDependencies": {
2828
"@types/node": "12.11.5 - 12.20.42",

samples/client/petstore/typescript-axios/builds/with-npm-version/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"prepare": "npm run build"
2323
},
2424
"dependencies": {
25-
"axios": "^1.13.5"
25+
"axios": "^1.6.1"
2626
},
2727
"devDependencies": {
2828
"@types/node": "12.11.5 - 12.20.42",

samples/client/petstore/typescript-fetch/builds/default-v3.0/models/MapTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ export interface MapTest {
2727
mapMapOfString?: { [key: string]: { [key: string]: string; }; };
2828
/**
2929
*
30-
* @type {{ [key: string]: MapTestMapOfEnumStringEnum; }}
30+
* @type {{ [key: string]: string; }}
3131
* @memberof MapTest
3232
*/
33-
mapOfEnumString?: { [key: string]: MapTestMapOfEnumStringEnum; };
33+
mapOfEnumString?: { [key: string]: string; };
3434
/**
3535
*
3636
* @type {{ [key: string]: boolean; }}

samples/client/petstore/typescript-fetch/builds/snakecase-discriminator/models/MapTest.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ export interface MapTest {
2727
mapMapOfString?: { [key: string]: { [key: string]: string; }; };
2828
/**
2929
*
30-
* @type {{ [key: string]: MapTestMapOfEnumStringEnum; }}
30+
* @type {{ [key: string]: string; }}
3131
* @memberof MapTest
3232
*/
33-
mapOfEnumString?: { [key: string]: MapTestMapOfEnumStringEnum; };
33+
mapOfEnumString?: { [key: string]: string; };
3434
/**
3535
*
3636
* @type {{ [key: string]: boolean; }}

0 commit comments

Comments
 (0)