forked from loafle/openapi-generator-original
Use the first status code in 2XX range, fallback to 200 (#12637)
This is in line with the OpenAPI specification: The Responses Object MUST contain at least one response code, and it SHOULD be the response for a successful operation call. and excludes the 2XX range response itself.
This commit is contained in:
parent
728c80abea
commit
ac9e595476
@ -576,7 +576,16 @@ public class HaskellServantCodegen extends DefaultCodegen implements CodegenConf
|
|||||||
if (returnType.indexOf(" ") >= 0) {
|
if (returnType.indexOf(" ") >= 0) {
|
||||||
returnType = "(" + returnType + ")";
|
returnType = "(" + returnType + ")";
|
||||||
}
|
}
|
||||||
path.add("Verb '" + op.httpMethod.toUpperCase(Locale.ROOT) + " 200 '[JSON] " + returnType);
|
|
||||||
|
String code = "200";
|
||||||
|
for (CodegenResponse r : op.responses) {
|
||||||
|
if (r.code.matches("2[0-9][0-9]")) {
|
||||||
|
code = r.code;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
path.add("Verb '" + op.httpMethod.toUpperCase(Locale.ROOT) + " " + code + " '[JSON] " + returnType);
|
||||||
type.add("m " + returnType);
|
type.add("m " + returnType);
|
||||||
|
|
||||||
op.vendorExtensions.put("x-route-type", joinStrings(" :> ", path));
|
op.vendorExtensions.put("x-route-type", joinStrings(" :> ", path));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user