mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2026-03-18 03:49:12 +00:00
Fix issue with Ruby client where strings from example properties are not wrapped with quotes (#987)
This commit is contained in:
committed by
William Cheng
parent
eb5a8cc752
commit
63b1c233c9
@@ -18,6 +18,8 @@
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.media.Schema;
|
||||
import io.swagger.v3.oas.models.parameters.Parameter;
|
||||
import io.swagger.v3.oas.models.examples.Example;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.slf4j.Logger;
|
||||
@@ -536,6 +538,34 @@ public class RubyClientCodegen extends AbstractRubyCodegen {
|
||||
p.example = example;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the example value of the parameter. Overrides the
|
||||
* setParameterExampleValue(CodegenParameter, Parameter) method in
|
||||
* DefaultCodegen to always call setParameterExampleValue(CodegenParameter)
|
||||
* in this class, which adds single quotes around strings from the
|
||||
* x-example property.
|
||||
*
|
||||
* @param codegenParameter Codegen parameter
|
||||
* @param parameter Parameter
|
||||
*/
|
||||
public void setParameterExampleValue(CodegenParameter codegenParameter, Parameter parameter) {
|
||||
if (parameter.getExample() != null) {
|
||||
codegenParameter.example = parameter.getExample().toString();
|
||||
} else if (parameter.getExamples() != null && !parameter.getExamples().isEmpty()) {
|
||||
Example example = parameter.getExamples().values().iterator().next();
|
||||
if (example.getValue() != null) {
|
||||
codegenParameter.example = example.getValue().toString();
|
||||
}
|
||||
} else {
|
||||
Schema schema = parameter.getSchema();
|
||||
if (schema != null && schema.getExample() != null) {
|
||||
codegenParameter.example = schema.getExample().toString();
|
||||
}
|
||||
}
|
||||
|
||||
setParameterExampleValue(codegenParameter);
|
||||
}
|
||||
|
||||
public void setGemName(String gemName) {
|
||||
this.gemName = gemName;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user