Replaced isSuccessCode with is2xx

This commit is contained in:
Tino Fuhrmann
2020-05-23 19:01:24 +02:00
parent 41d1864d02
commit dee6ed420e
4 changed files with 9 additions and 11 deletions

View File

@@ -28,7 +28,6 @@ public class CodegenResponse implements IJsonSchemaValidationProperties {
public boolean is4xx;
public boolean is5xx;
public String message;
public boolean isSuccessCode;
public boolean hasMore;
public List<Map<String, Object>> examples;
public String dataType;

View File

@@ -3800,7 +3800,6 @@ public class DefaultCodegen implements CodegenConfig {
default:
throw new RuntimeException("Invalid response code " + responseCode);
}
r.isSuccessCode = r.code.startsWith("2");
}
Schema responseSchema;
if (this.openAPI != null && this.openAPI.getComponents() != null) {

View File

@@ -318,7 +318,7 @@ public class TypeScriptClientCodegen extends DefaultCodegen implements CodegenCo
boolean addVoid = false;
for (CodegenResponse response: responses) {
// TODO: we should probably catch an exception here
if (response.isSuccessCode) {
if (response.is2xx) {
if (response.dataType != null) {
if (!firstReturnType) {
returnType.append(" | ");

View File

@@ -166,20 +166,20 @@ export class {{classname}}ResponseProcessor {
"{{{dataType}}}", "{{returnFormat}}"
) as {{{dataType}}};
{{/isBinary}}
{{#isSuccessCode}}
{{#is2xx}}
return body;
{{/isSuccessCode}}
{{^isSuccessCode}}
{{/is2xx}}
{{^is2xx}}
throw new ApiException<{{{dataType}}}>({{code}}, body);
{{/isSuccessCode}}
{{/is2xx}}
{{/dataType}}
{{^dataType}}
{{#isSuccessCode}}
{{#is2xx}}
return;
{{/isSuccessCode}}
{{^isSuccessCode}}
{{/is2xx}}
{{^is2xx}}
throw new ApiException<string>(response.httpStatusCode, "{{message}}");
{{/isSuccessCode}}
{{/is2xx}}
{{/dataType}}
}
{{/responses}}