Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow set request body name with extension #827

Merged
merged 1 commit into from
Dec 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2150,8 +2150,12 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation
CodegenParameter codegenParameter = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
codegenParameter.description = body.getDescription();
codegenParameter.unescapedDescription = body.getDescription();
codegenParameter.baseName = REQUEST_BODY_NAME;
codegenParameter.paramName = REQUEST_BODY_NAME;
String bodyName = REQUEST_BODY_NAME;
if (body.getExtensions() != null && body.getExtensions().get("x-codegen-request-body-name") != null) {
bodyName = body.getExtensions().get("x-codegen-request-body-name").toString();
}
codegenParameter.baseName = bodyName;
codegenParameter.paramName = bodyName;
codegenParameter.dataType = "Object";
codegenParameter.baseType = "Object";

Expand Down Expand Up @@ -2653,8 +2657,13 @@ else if (parameter instanceof FormParameter) {

public CodegenParameter fromRequestBody(RequestBody body, String name, Schema schema, Map<String, Schema> schemas, Set<String> imports) {
CodegenParameter codegenParameter = CodegenModelFactory.newInstance(CodegenModelType.PARAMETER);
codegenParameter.baseName = REQUEST_BODY_NAME;
codegenParameter.paramName = REQUEST_BODY_NAME;

String bodyName = REQUEST_BODY_NAME;
if (body.getExtensions() != null && body.getExtensions().get("x-codegen-request-body-name") != null) {
bodyName = body.getExtensions().get("x-codegen-request-body-name").toString();
}
codegenParameter.baseName = bodyName;
codegenParameter.paramName = bodyName;
codegenParameter.description = body.getDescription();
codegenParameter.unescapedDescription = body.getDescription();
codegenParameter.required = body.getRequired() != null ? body.getRequired() : Boolean.FALSE;
Expand Down Expand Up @@ -2765,7 +2774,7 @@ else if (schema instanceof BinarySchema) {
codegenParameter.getVendorExtensions().put(CodegenConstants.IS_BINARY_EXT_NAME, Boolean.TRUE);
}
else {
CodegenProperty codegenProperty = fromProperty(REQUEST_BODY_NAME, schema);
CodegenProperty codegenProperty = fromProperty(bodyName, schema);
codegenParameter.dataType = codegenProperty.datatype;
codegenParameter.baseType = codegenProperty.baseType;
if (codegenProperty.complexType != null) {
Expand Down