From 0f5fd3aac7a7db83dc1a60447ba4ae192f37742e Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Thu, 14 May 2020 21:01:26 -0400 Subject: [PATCH 01/16] [breaking] Enforce vendor extension naming convention --- .../languages/AbstractApexCodegen.java | 7 -- .../languages/AbstractCSharpCodegen.java | 3 - .../languages/AbstractEiffelCodegen.java | 5 -- .../codegen/languages/AbstractGoCodegen.java | 13 --- .../languages/AbstractJavaCodegen.java | 5 -- .../codegen/languages/AbstractPhpCodegen.java | 5 -- .../languages/Apache2ConfigCodegen.java | 5 -- .../languages/ClojureClientCodegen.java | 7 -- .../languages/CppPistacheServerCodegen.java | 7 -- .../languages/CppRestbedServerCodegen.java | 5 -- .../languages/DartDioClientCodegen.java | 11 --- .../languages/DartJaguarClientCodegen.java | 12 --- .../languages/HaskellHttpClientCodegen.java | 81 +++---------------- .../languages/HaskellServantCodegen.java | 12 --- .../codegen/languages/JavaClientCodegen.java | 12 +-- .../languages/JavaPlayFrameworkCodegen.java | 5 -- .../JavascriptApolloClientCodegen.java | 18 ----- .../languages/JavascriptClientCodegen.java | 18 ----- .../codegen/languages/MysqlSchemaCodegen.java | 68 +++++++--------- .../codegen/languages/OCamlClientCodegen.java | 4 - .../codegen/languages/ObjcClientCodegen.java | 9 --- .../languages/PhpSymfonyServerCodegen.java | 17 ---- .../codegen/languages/RustClientCodegen.java | 5 -- .../codegen/languages/RustServerCodegen.java | 75 +---------------- .../languages/ScalaFinchServerCodegen.java | 18 ----- .../ScalaPlayFrameworkServerCodegen.java | 9 --- .../languages/StaticHtml2Generator.java | 9 --- .../TypeScriptRxjsClientCodegen.java | 4 - .../utils/OneOfImplementorAdditionalData.java | 11 +-- .../OneOfImplementorAdditionalDataTest.java | 2 +- 30 files changed, 52 insertions(+), 410 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java index bb2a21d4afa9..8b1cb5ee8eda 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractApexCodegen.java @@ -456,13 +456,6 @@ public CodegenModel fromModel(String name, Schema model) { } } - // TODO: 5.0: Remove this block and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - cm.vendorExtensions.put("hasPropertyMappings", !propertyMappings.isEmpty()); // TODO: 5.0 Remove - cm.vendorExtensions.put("hasDefaultValues", hasDefaultValues); // TODO: 5.0 Remove - cm.vendorExtensions.put("propertyMappings", propertyMappings); // TODO: 5.0 Remove - - cm.vendorExtensions.put("x-has-property-mappings", !propertyMappings.isEmpty()); cm.vendorExtensions.put("x-has-default-values", hasDefaultValues); cm.vendorExtensions.put("x-property-mappings", propertyMappings); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java index 66af4e39a872..92ceaddf88ad 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractCSharpCodegen.java @@ -590,14 +590,11 @@ public void updateCodegenPropertyEnum(CodegenProperty var) { * @param models list of all models */ protected void updateValueTypeProperty(Map models) { - // TODO: 5.0: Remove the camelCased vendorExtension within the below loop and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); for (Map.Entry entry : models.entrySet()) { String openAPIName = entry.getKey(); CodegenModel model = ModelUtils.getModelByName(openAPIName, models); if (model != null) { for (CodegenProperty var : model.vars) { - var.vendorExtensions.put("isValueType", isValueType(var)); // TODO: 5.0 Remove var.vendorExtensions.put("x-is-value-type", isValueType(var)); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java index 6d8f5e97632b..ff4238ac6709 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractEiffelCodegen.java @@ -235,19 +235,14 @@ public void postProcessParameter(CodegenParameter parameter) { char firstChar = parameter.paramName.charAt(0); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - if (Character.isUpperCase(firstChar)) { // First char is already uppercase, just use paramName. - parameter.vendorExtensions.put("x-exportParamName", parameter.paramName); // TODO: 5.0 Remove parameter.vendorExtensions.put("x-export-param-name", parameter.paramName); } // It's a lowercase first char, let's convert it to uppercase StringBuilder sb = new StringBuilder(parameter.paramName); sb.setCharAt(0, Character.toUpperCase(firstChar)); - parameter.vendorExtensions.put("x-exportParamName", sb.toString()); // TODO: 5.0 Remove parameter.vendorExtensions.put("x-export-param-name", sb.toString()); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java index d9d916d9079f..de146e4d8724 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java @@ -457,9 +457,6 @@ public Map postProcessOperationsWithModels(Map o @SuppressWarnings("unchecked") List operations = (List) objectMap.get("operation"); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (CodegenOperation operation : operations) { // http method verb conversion (e.g. PUT => Put) operation.httpMethod = camelize(operation.httpMethod.toLowerCase(Locale.ROOT)); @@ -525,12 +522,10 @@ public Map postProcessOperationsWithModels(Map o // We need to specially map Time type to the optionals package if ("time.Time".equals(param.dataType)) { - param.vendorExtensions.put("x-optionalDataType", "Time"); // TODO: 5.0 Remove param.vendorExtensions.put("x-optional-data-type", "Time"); } else { // Map optional type to dataType String optionalType = param.dataType.substring(0, 1).toUpperCase(Locale.ROOT) + param.dataType.substring(1); - param.vendorExtensions.put("x-optionalDataType", optionalType); // TODO: 5.0 Remove param.vendorExtensions.put("x-optional-data-type", optionalType); } } @@ -539,13 +534,11 @@ public Map postProcessOperationsWithModels(Map o char nameFirstChar = param.paramName.charAt(0); if (Character.isUpperCase(nameFirstChar)) { // First char is already uppercase, just use paramName. - param.vendorExtensions.put("x-exportParamName", param.paramName); // TODO: 5.0 Remove param.vendorExtensions.put("x-export-param-name", param.paramName); } else { // It's a lowercase first char, let's convert it to uppercase StringBuilder sb = new StringBuilder(param.paramName); sb.setCharAt(0, Character.toUpperCase(nameFirstChar)); - param.vendorExtensions.put("x-exportParamName", sb.toString()); // TODO: 5.0 Remove param.vendorExtensions.put("x-export-param-name", sb.toString()); } } @@ -579,21 +572,15 @@ public Map postProcessOperationsWithModels(Map o } private void setExportParameterName(List codegenParameters) { - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (CodegenParameter param : codegenParameters) { char nameFirstChar = param.paramName.charAt(0); if (Character.isUpperCase(nameFirstChar)) { // First char is already uppercase, just use paramName. - param.vendorExtensions.put("x-exportParamName", param.paramName); // TODO: 5.0 Remove param.vendorExtensions.put("x-export-param-name", param.paramName); } else { // It's a lowercase first char, let's convert it to uppercase StringBuilder sb = new StringBuilder(param.paramName); sb.setCharAt(0, Character.toUpperCase(nameFirstChar)); - param.vendorExtensions.put("x-exportParamName", sb.toString()); // TODO: 5.0 Remove param.vendorExtensions.put("x-export-param-name", sb.toString()); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java index 2ba884ebb86c..e2c09ba0faee 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java @@ -1024,12 +1024,7 @@ public CodegenModel fromModel(String name, Schema model) { public void postProcessModelProperty(CodegenModel model, CodegenProperty property) { if (serializeBigDecimalAsString) { if (property.baseType.equals("BigDecimal")) { - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - // we serialize BigDecimal as `string` to avoid precision loss - property.vendorExtensions.put("extraAnnotation", "@JsonSerialize(using = ToStringSerializer.class)"); // TODO: 5.0 Remove property.vendorExtensions.put("x-extra-annotation", "@JsonSerialize(using = ToStringSerializer.class)"); // this requires some more imports to be added for this model... diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java index 7395186f4843..b30c5a899bd6 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractPhpCodegen.java @@ -675,14 +675,9 @@ public Map postProcessModels(Map objs) { public Map postProcessOperationsWithModels(Map objs, List allModels) { Map operations = (Map) objs.get("operations"); List operationList = (List) operations.get("operation"); - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (CodegenOperation op : operationList) { // for API test method name // e.g. public function test{{vendorExtensions.x-testOperationId}}() - op.vendorExtensions.put("x-testOperationId", camelize(op.operationId)); // TODO: 5.0 Remove op.vendorExtensions.put("x-test-operation-id", camelize(op.operationId)); } return objs; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Apache2ConfigCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Apache2ConfigCodegen.java index 5cd7dfb6c679..cd0a392fb23d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Apache2ConfigCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/Apache2ConfigCodegen.java @@ -96,9 +96,6 @@ public Map postProcessOperationsWithModels(Map o List operationList = (List) operations.get("operation"); List newOpList = new ArrayList(); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (CodegenOperation op : operationList) { String path = op.path; @@ -111,7 +108,6 @@ public Map postProcessOperationsWithModels(Map o splitPath.add(item); op.path += item + "/"; } - op.vendorExtensions.put("x-codegen-userInfoPath", userInfoPath); // TODO: 5.0 Remove op.vendorExtensions.put("x-codegen-user-info-path", userInfoPath); boolean foundInNewList = false; for (CodegenOperation op1 : newOpList) { @@ -124,7 +120,6 @@ public Map postProcessOperationsWithModels(Map o } op.operationIdCamelCase = op1.operationIdCamelCase; currentOtherMethodList.add(op); - op1.vendorExtensions.put("x-codegen-otherMethods", currentOtherMethodList); // TODO: 5.0 Remove op1.vendorExtensions.put("x-codegen-other-methods", currentOtherMethodList); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ClojureClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ClojureClientCodegen.java index cb31f4f895d4..5af22a8d3f8f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ClojureClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ClojureClientCodegen.java @@ -47,7 +47,6 @@ public class ClojureClientCodegen extends DefaultCodegen implements CodegenConfi private static final String PROJECT_LICENSE_URL = "projectLicenseUrl"; private static final String BASE_NAMESPACE = "baseNamespace"; - static final String X_BASE_SPEC = "x-baseSpec"; // TODO: 5.0 Remove static final String VENDOR_EXTENSION_X_BASE_SPEC = "x-base-spec"; static final String X_MODELS = "x-models"; @@ -202,16 +201,10 @@ public String toModelName(String name) { @Override public CodegenModel fromModel(String name, Schema mod) { CodegenModel model = super.fromModel(name, mod); - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - // If a var is a base spec we won't need to import it for (CodegenProperty var : model.vars) { - var.vendorExtensions.put(X_BASE_SPEC, baseSpecs.contains(var.complexType)); // TODO: 5.0 Remove var.vendorExtensions.put(VENDOR_EXTENSION_X_BASE_SPEC, baseSpecs.contains(var.complexType)); if (var.items != null) { - var.items.vendorExtensions.put(X_BASE_SPEC, baseSpecs.contains(var.items.complexType)); // TODO: 5.0 Remove var.items.vendorExtensions.put(VENDOR_EXTENSION_X_BASE_SPEC, baseSpecs.contains(var.items.complexType)); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java index 88637961ccc1..ad3b01873221 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppPistacheServerCodegen.java @@ -253,10 +253,6 @@ public Map postProcessOperationsWithModels(Map o String classname = (String) operations.get("classname"); operations.put("classnameSnakeUpperCase", underscore(classname).toUpperCase(Locale.ROOT)); operations.put("classnameSnakeLowerCase", underscore(classname).toLowerCase(Locale.ROOT)); - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - List operationList = (List) operations.get("operation"); for (CodegenOperation op : operationList) { boolean consumeJson = false; @@ -267,7 +263,6 @@ public Map postProcessOperationsWithModels(Map o } boolean isStringOrDate = op.bodyParam.isString || op.bodyParam.isDate; - op.bodyParam.vendorExtensions.put("x-codegen-pistache-isStringOrDate", isStringOrDate); // TODO: 5.0 Remove op.bodyParam.vendorExtensions.put("x-codegen-pistache-is-string-or-date", isStringOrDate); } if (op.consumes != null) { @@ -302,9 +297,7 @@ public Map postProcessOperationsWithModels(Map o if (op.vendorExtensions == null) { op.vendorExtensions = new HashMap<>(); } - op.vendorExtensions.put("x-codegen-pistache-consumesJson", consumeJson); // TODO: 5.0 Remove op.vendorExtensions.put("x-codegen-pistache-consumes-json", consumeJson); - op.vendorExtensions.put("x-codegen-pistache-isParsingSupported", isParsingSupported); // TODO: 5.0 Remove op.vendorExtensions.put("x-codegen-pistache-is-parsing-supported", isParsingSupported); // Check if any one of the operations needs a model, then at API file level, at least one model has to be included. diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestbedServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestbedServerCodegen.java index 3234cfb4c9fb..f8ccbf448102 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestbedServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppRestbedServerCodegen.java @@ -287,9 +287,6 @@ public Map postProcessOperationsWithModels(Map o List operationList = (List) operations.get("operation"); List newOpList = new ArrayList(); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (CodegenOperation op : operationList) { String path = op.path; @@ -311,7 +308,6 @@ public Map postProcessOperationsWithModels(Map o } op.path += item + "/"; } - op.vendorExtensions.put("x-codegen-resourceName", resourceNameCamelCase); // TODO: 5.0 Remove op.vendorExtensions.put("x-codegen-resource-name", resourceNameCamelCase); boolean foundInNewList = false; @@ -325,7 +321,6 @@ public Map postProcessOperationsWithModels(Map o } op.operationIdCamelCase = op1.operationIdCamelCase; currentOtherMethodList.add(op); - op1.vendorExtensions.put("x-codegen-otherMethods", currentOtherMethodList); // TODO: 5.0 Remove op1.vendorExtensions.put("x-codegen-other-methods", currentOtherMethodList); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java index 9c06fb029b7a..8bff9e8f64fe 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartDioClientCodegen.java @@ -270,9 +270,6 @@ public Map postProcessModels(Map objs) { List models = (List) objs.get("models"); ProcessUtils.addIndexToProperties(models, 1); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (Object _mo : models) { Map mo = (Map) _mo; Set modelImports = new HashSet<>(); @@ -289,7 +286,6 @@ public Map postProcessModels(Map objs) { cm.imports = modelImports; boolean hasVars = cm.vars.size() > 0; - cm.vendorExtensions.put("hasVars", hasVars); // TODO: 5.0 Remove cm.vendorExtensions.put("x-has-vars", hasVars); } return objs; @@ -356,13 +352,6 @@ public Map postProcessOperationsWithModels(Map o } } - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - - op.vendorExtensions.put("isJson", isJson); // TODO: 5.0 Remove - op.vendorExtensions.put("isForm", isForm); // TODO: 5.0 Remove - op.vendorExtensions.put("isMultipart", isMultipart); // TODO: 5.0 Remove - op.vendorExtensions.put("x-is-json", isJson); op.vendorExtensions.put("x-is-form", isForm); op.vendorExtensions.put("x-is-multipart", isMultipart); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java index eabb64854a4c..c5042947a17b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/DartJaguarClientCodegen.java @@ -225,9 +225,6 @@ public Map postProcessModels(Map objs) { List models = (List) objs.get("models"); ProcessUtils.addIndexToProperties(models, 1); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (Object _mo : models) { Map mo = (Map) _mo; Set modelImports = new HashSet<>(); @@ -249,7 +246,6 @@ public Map postProcessModels(Map objs) { cm.imports = modelImports; boolean hasVars = cm.vars.size() > 0; - cm.vendorExtensions.put("hasVars", hasVars); // TODO: 5.0 Remove cm.vendorExtensions.put("x-has-vars", hasVars); } return objs; @@ -259,9 +255,6 @@ public Map postProcessModels(Map objs) { public Map postProcessOperationsWithModels(Map objs, List allModels) { objs = super.postProcessOperationsWithModels(objs, allModels); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - Map operations = (Map) objs.get("operations"); List operationList = (List) operations.get("operation"); @@ -305,11 +298,6 @@ public Map postProcessOperationsWithModels(Map o } } - op.vendorExtensions.put("isForm", isForm); // TODO: 5.0 Remove - op.vendorExtensions.put("isJson", isJson); // TODO: 5.0 Remove - op.vendorExtensions.put("isProto", isProto); // TODO: 5.0 Remove - op.vendorExtensions.put("isMultipart", isMultipart); // TODO: 5.0 Remove - op.vendorExtensions.put("x-is-form", isForm); op.vendorExtensions.put("x-is-json", isJson); op.vendorExtensions.put("x-is-proto", isProto); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java index 15a37e681e88..7b1831b052c2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellHttpClientCodegen.java @@ -38,7 +38,6 @@ import java.util.regex.Pattern; import java.util.stream.Collectors; -import static org.openapitools.codegen.utils.OnceLogger.once; import static org.openapitools.codegen.utils.StringUtils.camelize; import static org.openapitools.codegen.utils.StringUtils.underscore; @@ -88,24 +87,7 @@ public class HaskellHttpClientCodegen extends DefaultCodegen implements CodegenC static final String MIME_ANY = "MimeAny"; // vendor extensions. These must follow our convention of x- prefixed and lower-kebab cased. - static final String X_COLLECTION_FORMAT = "x-collectionFormat"; // TODO: 5.0 Remove - static final String X_HADDOCK_PATH = "x-haddockPath"; // TODO: 5.0 Remove - static final String X_HAS_BODY_OR_FORM_PARAM = "x-hasBodyOrFormParam"; // TODO: 5.0 Remove - static final String X_HAS_MIME_FORM_URL_ENCODED = "x-hasMimeFormUrlEncoded"; // TODO: 5.0 Remove - static final String X_HAS_NEW_TAG = "x-hasNewTag"; // TODO: 5.0 Remove - static final String X_HAS_OPTIONAL_PARAMS = "x-hasOptionalParams"; // TODO: 5.0 Remove - static final String X_HAS_UNKNOWN_RETURN = "x-hasUnknownReturn"; // TODO: 5.0 Remove - static final String X_INLINE_CONTENT_TYPE = "x-inlineContentType"; // TODO: 5.0 Remove - static final String X_INLINE_ACCEPT = "x-inlineAccept"; // TODO: 5.0 Remove - static final String X_IS_BODY_OR_FORM_PARAM = "x-isBodyOrFormParam"; // TODO: 5.0 Remove - static final String X_IS_MAYBE_VALUE = "x-isMaybeValue"; // TODO: 5.0 Remove - static final String X_DATA_TYPE = "x-dataType"; // TODO: 5.0 Remove - static final String X_MIME_TYPES = "x-mimeTypes"; // TODO: 5.0 Remove - static final String X_OPERATION_TYPE = "x-operationType"; // TODO: 5.0 Remove - static final String X_PARAM_NAME_TYPE = "x-paramNameType"; // TODO: 5.0 Remove - static final String X_RETURN_TYPE = "x-returnType"; // TODO: 5.0 Remove - static final String X_UNKNOWN_MIME_TYPES = "x-unknownMimeTypes"; // TODO: 5.0 Remove - + static final String VENDOR_EXTENSION_X_UNKNOWN_MIME_TYPES = "x-unknown-mime-types"; static final String VENDOR_EXTENSION_X_COLLECTION_FORMAT = "x-collection-format"; static final String VENDOR_EXTENSION_X_HADDOCK_PATH = "x-haddock-path"; static final String VENDOR_EXTENSION_X_HAS_BODY_OR_FORM_PARAM = "x-has-body-or-form-param"; @@ -687,10 +669,6 @@ public String toInstantiationType(Schema p) { @Override public void addOperationToGroup(String tag, String resourcePath, Operation operation, CodegenOperation op, Map> operations) { - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - List opList = operations.get(tag); if (opList == null || opList.isEmpty()) { opList = new ArrayList(); @@ -727,33 +705,25 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera op.vendorExtensions = new LinkedHashMap(); String operationType = toTypeName("Op", op.operationId); - op.vendorExtensions.put(X_OPERATION_TYPE, operationType); // TODO: 5.0 Remove op.vendorExtensions.put(VENDOR_EXTENSION_X_OPERATION_TYPE, operationType); typeNames.add(operationType); String xHaddockPath = String.format(Locale.ROOT, "%s %s", op.httpMethod, op.path.replace("/", "\\/")); - op.vendorExtensions.put(X_HADDOCK_PATH, xHaddockPath); // TODO: 5.0 Remove op.vendorExtensions.put(VENDOR_EXTENSION_X_HADDOCK_PATH, xHaddockPath); - op.vendorExtensions.put(X_HAS_BODY_OR_FORM_PARAM, op.getHasBodyParam() || op.getHasFormParams()); // TODO: 5.0 Remove op.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_BODY_OR_FORM_PARAM, op.getHasBodyParam() || op.getHasFormParams()); for (CodegenParameter param : op.allParams) { param.vendorExtensions = new LinkedHashMap(); // prevent aliasing/sharing - param.vendorExtensions.put(X_OPERATION_TYPE, operationType); // TODO: 5.0 Remove param.vendorExtensions.put(VENDOR_EXTENSION_X_OPERATION_TYPE, operationType); - param.vendorExtensions.put(X_IS_BODY_OR_FORM_PARAM, param.isBodyParam || param.isFormParam); // TODO: 5.0 Remove param.vendorExtensions.put(VENDOR_EXTENSION_X_IS_BODY_OR_FORM_PARAM, param.isBodyParam || param.isFormParam); if (!StringUtils.isBlank(param.collectionFormat)) { - param.vendorExtensions.put(X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat)); // TODO: 5.0 Remove param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat)); } else if (!param.isBodyParam && (param.isListContainer || param.dataType.startsWith("["))) { // param.isListContainer is sometimes false for list types // defaulting due to https://github.com/wing328/openapi-generator/issues/72 param.collectionFormat = "csv"; - param.vendorExtensions.put(X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat)); // TODO: 5.0 Remove param.vendorExtensions.put(VENDOR_EXTENSION_X_COLLECTION_FORMAT, mapCollectionFormat(param.collectionFormat)); } if (!param.required) { - op.vendorExtensions.put(X_HAS_OPTIONAL_PARAMS, true); // TODO: 5.0 Remove op.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_OPTIONAL_PARAMS, true); } @@ -764,7 +734,6 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera String dataType = genEnums && param.isEnum ? param.datatypeWithEnum : param.dataType; String paramNameType = toDedupedModelName(toTypeName("Param", param.paramName), dataType, !param.isEnum); - param.vendorExtensions.put(X_PARAM_NAME_TYPE, paramNameType); // TODO: 5.0 Remove param.vendorExtensions.put(VENDOR_EXTENSION_X_PARAM_NAME_TYPE, paramNameType); HashMap props = new HashMap<>(); @@ -809,16 +778,16 @@ public int compare(Map o1, Map o2) { return o1.get(MEDIA_TYPE).compareTo(o2.get(MEDIA_TYPE)); } }); - additionalProperties.put(X_UNKNOWN_MIME_TYPES, unknownMimeTypes); + additionalProperties.put(VENDOR_EXTENSION_X_UNKNOWN_MIME_TYPES, unknownMimeTypes); ArrayList> params = new ArrayList<>(uniqueParamNameTypes.values()); Collections.sort(params, new Comparator>() { @Override public int compare(Map o1, Map o2) { return - ((String) o1.get(X_PARAM_NAME_TYPE)) + ((String) o1.get(VENDOR_EXTENSION_X_PARAM_NAME_TYPE)) .compareTo( - (String) o2.get(X_PARAM_NAME_TYPE)); + (String) o2.get(VENDOR_EXTENSION_X_PARAM_NAME_TYPE)); } }); additionalProperties.put(X_ALL_UNIQUE_PARAMS, params); @@ -827,14 +796,9 @@ public int compare(Map o1, Map o2) { @Override public Map postProcessOperationsWithModels(Map objs, List allModels) { Map ret = super.postProcessOperationsWithModels(objs, allModels); - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - HashMap pathOps = (HashMap) ret.get("operations"); ArrayList ops = (ArrayList) pathOps.get("operation"); if (ops.size() > 0) { - ops.get(0).vendorExtensions.put(X_HAS_NEW_TAG, true); // TODO: 5.0 Remove ops.get(0).vendorExtensions.put(VENDOR_EXTENSION_X_HAS_NEW_TAG, true); } @@ -846,7 +810,6 @@ public Map postProcessOperationsWithModels(Map o if (modelMimeTypes.containsKey(m.classname)) { Set mimeTypes = modelMimeTypes.get(m.classname); - m.vendorExtensions.put(X_MIME_TYPES, mimeTypes); // TODO: 5.0 Remove m.vendorExtensions.put(VENDOR_EXTENSION_X_MIME_TYPES, mimeTypes); if ((boolean) additionalProperties.get(PROP_GENERATE_FORM_URLENCODED_INSTANCES) && mimeTypes.contains("MimeFormUrlEncoded")) { @@ -857,7 +820,6 @@ public Map postProcessOperationsWithModels(Map o } } if (hasMimeFormUrlEncoded) { - m.vendorExtensions.put(X_HAS_MIME_FORM_URL_ENCODED, true); // TODO: 5.0 Remove m.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_MIME_FORM_URL_ENCODED, true); } } @@ -919,14 +881,9 @@ private void processReturnType(CodegenOperation op) { if (returnType == null || returnType.equals("null")) { if (op.hasProduces) { returnType = "res"; - op.vendorExtensions.put(X_HAS_UNKNOWN_RETURN, true); // TODO: 5.0 Remove op.vendorExtensions.put(VENDOR_EXTENSION_X_HAS_UNKNOWN_RETURN, true); } else { returnType = "NoContent"; - // TODO: 5.0 Remove vendor extension usage which is not lower-kebab cased. - if (!op.vendorExtensions.containsKey(X_INLINE_ACCEPT)) { - SetNoContent(op, X_INLINE_ACCEPT); - } if (!op.vendorExtensions.containsKey(VENDOR_EXTENSION_X_INLINE_ACCEPT)) { SetNoContent(op, VENDOR_EXTENSION_X_INLINE_ACCEPT); } @@ -935,13 +892,11 @@ private void processReturnType(CodegenOperation op) { if (returnType.contains(" ")) { returnType = "(" + returnType + ")"; } - op.vendorExtensions.put(X_RETURN_TYPE, returnType); // TODO: 5.0 Remove op.vendorExtensions.put(VENDOR_EXTENSION_X_RETURN_TYPE, returnType); } private void processProducesConsumes(CodegenOperation op) { - if (!(Boolean) op.vendorExtensions.get(X_HAS_BODY_OR_FORM_PARAM)) { - SetNoContent(op, X_INLINE_CONTENT_TYPE); // TODO: 5.0 Remove + if (!(Boolean) op.vendorExtensions.get(VENDOR_EXTENSION_X_HAS_BODY_OR_FORM_PARAM)) { SetNoContent(op, VENDOR_EXTENSION_X_INLINE_CONTENT_TYPE); } if (op.hasConsumes) { @@ -979,20 +934,15 @@ private void processProducesConsumes(CodegenOperation op) { } private void processInlineConsumesContentType(CodegenOperation op, Map m) { - if (op.vendorExtensions.containsKey(X_INLINE_CONTENT_TYPE)) return; - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); + if (op.vendorExtensions.containsKey(VENDOR_EXTENSION_X_INLINE_CONTENT_TYPE)) return; if ((boolean) additionalProperties.get(PROP_INLINE_MIME_TYPES) && op.consumes.size() == 1 && !MIME_ANY.equals(op.consumes.get(0).get(X_MEDIA_DATA_TYPE)) && !MIME_NO_CONTENT.equals(op.consumes.get(0).get(X_MEDIA_DATA_TYPE))) { - op.vendorExtensions.put(X_INLINE_CONTENT_TYPE, m); // TODO: 5.0 Remove op.vendorExtensions.put(VENDOR_EXTENSION_X_INLINE_CONTENT_TYPE, m); for (CodegenParameter param : op.allParams) { if (param.isBodyParam && param.required) { - param.vendorExtensions.put(X_INLINE_CONTENT_TYPE, m); // TODO: 5.0 Remove param.vendorExtensions.put(VENDOR_EXTENSION_X_INLINE_CONTENT_TYPE, m); } } @@ -1005,10 +955,6 @@ private void processInlineProducesContentType(CodegenOperation op, Map lastParam = this.uniqueParamNameTypes.get(paramNameType); if (lastParam != null) { - String comparisonKey = lastParam.containsKey(VENDOR_EXTENSION_X_ENUM) ? X_ENUM_VALUES : X_DATA_TYPE; + String comparisonKey = lastParam.containsKey(VENDOR_EXTENSION_X_ENUM) ? X_ENUM_VALUES : VENDOR_EXTENSION_X_DATA_TYPE; String lastParamDataType = (String) lastParam.get(comparisonKey); if (lastParamDataType != null && lastParamDataType.equals(dataType)) { return true; @@ -1053,7 +999,7 @@ public Boolean isDuplicate(String paramNameType, String dataType) { private Pair isDuplicateEnumValues(String enumValues) { for (Map vs : uniqueParamNameTypes.values()) { if (enumValues.equals(vs.get(X_ENUM_VALUES))) { - return Pair.of(true, (String) vs.get(X_PARAM_NAME_TYPE)); + return Pair.of(true, (String) vs.get(VENDOR_EXTENSION_X_PARAM_NAME_TYPE)); } } return Pair.of(false, null); @@ -1062,8 +1008,8 @@ private Pair isDuplicateEnumValues(String enumValues) { private void addToUniques(String xGroup, String paramNameType, String dataType, Map props) { HashMap m = new HashMap<>(); - m.put(X_PARAM_NAME_TYPE, paramNameType); - m.put(X_DATA_TYPE, dataType); + m.put(VENDOR_EXTENSION_X_PARAM_NAME_TYPE, paramNameType); + m.put(VENDOR_EXTENSION_X_DATA_TYPE, dataType); m.put(xGroup, true); m.putAll(props); uniqueParamNameTypes.put(paramNameType, m); @@ -1323,9 +1269,6 @@ public String toDefaultValue(Schema p) { public Map postProcessModels(Map objs) { List models = (List) objs.get("models"); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (Object _mo : models) { Map mo = (Map) _mo; CodegenModel cm = (CodegenModel) mo.get("model"); @@ -1335,10 +1278,8 @@ public Map postProcessModels(Map objs) { if (dataType == null && cm.isArrayModel) { // isAlias + arrayModelType missing "datatype" dataType = "[" + cm.arrayModelType + "]"; } - cm.vendorExtensions.put(X_DATA_TYPE, dataType); // TODO: 5.0 Remove cm.vendorExtensions.put(VENDOR_EXTENSION_X_DATA_TYPE, dataType); if (dataType.equals("Maybe A.Value")) { - cm.vendorExtensions.put(X_IS_MAYBE_VALUE, true); // TODO: 5.0 Remove cm.vendorExtensions.put(VENDOR_EXTENSION_X_IS_MAYBE_VALUE, true); } } @@ -1346,10 +1287,8 @@ public Map postProcessModels(Map objs) { String datatype = genEnums && !StringUtils.isBlank(var.datatypeWithEnum) ? var.datatypeWithEnum : var.dataType; - var.vendorExtensions.put(X_DATA_TYPE, datatype); // TODO: 5.0 Remove var.vendorExtensions.put(VENDOR_EXTENSION_X_DATA_TYPE, datatype); if (!var.required && datatype.equals("A.Value") || var.required && datatype.equals("Maybe A.Value")) { - var.vendorExtensions.put(X_IS_MAYBE_VALUE, true); // TODO: 5.0 Remove var.vendorExtensions.put(VENDOR_EXTENSION_X_IS_MAYBE_VALUE, true); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java index 024447f3dd33..e763f3c64528 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/HaskellServantCodegen.java @@ -507,9 +507,6 @@ private List pathToClientType(String path, List pathPa public CodegenOperation fromOperation(String resourcePath, String httpMethod, Operation operation, List servers) { CodegenOperation op = super.fromOperation(resourcePath, httpMethod, operation, servers); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - List path = pathToServantRoute(op.path, op.pathParams); List type = pathToClientType(op.path, op.pathParams); @@ -562,7 +559,6 @@ public CodegenOperation fromOperation(String resourcePath, String httpMethod, Op // store form parameter name in the vendor extensions for (CodegenParameter param : op.formParams) { - param.vendorExtensions.put("x-formParamName", camelize(param.baseName)); // TODO: 5.0 Remove param.vendorExtensions.put("x-form-param-name", camelize(param.baseName)); } @@ -577,14 +573,10 @@ public CodegenOperation fromOperation(String resourcePath, String httpMethod, Op path.add("Verb '" + op.httpMethod.toUpperCase(Locale.ROOT) + " 200 '[JSON] " + returnType); type.add("m " + returnType); - op.vendorExtensions.put("x-routeType", joinStrings(" :> ", path)); // TODO: 5.0 Remove op.vendorExtensions.put("x-route-type", joinStrings(" :> ", path)); - op.vendorExtensions.put("x-clientType", joinStrings(" -> ", type)); // TODO: 5.0 Remove op.vendorExtensions.put("x-client-type", joinStrings(" -> ", type)); - op.vendorExtensions.put("x-formName", "Form" + camelize(op.operationId)); // TODO: 5.0 Remove op.vendorExtensions.put("x-form-name", "Form" + camelize(op.operationId)); for (CodegenParameter param : op.formParams) { - param.vendorExtensions.put("x-formPrefix", camelize(op.operationId, true)); // TODO: 5.0 Remove param.vendorExtensions.put("x-form-prefix", camelize(op.operationId, true)); } return op; @@ -642,9 +634,6 @@ private String fixModelChars(String string) { public CodegenModel fromModel(String name, Schema mod) { CodegenModel model = super.fromModel(name, mod); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - setGenerateToSchema(model); // Clean up the class name to remove invalid characters @@ -663,7 +652,6 @@ public CodegenModel fromModel(String name, Schema mod) { String dataOrNewtype = "data"; if (!"object".equals(model.dataType) && typeMapping.containsKey(model.dataType)) { String newtype = typeMapping.get(model.dataType); - model.vendorExtensions.put("x-customNewtype", newtype); // TODO: 5.0 Remove // note; newtype is a single lowercase word in Haskell (not separated by hyphen) model.vendorExtensions.put("x-custom-newtype", newtype); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java index 2c305b30cd86..38fd11f04e9d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java @@ -776,14 +776,12 @@ public Map postProcessModelsEnum(Map objs) { return objs; } + @SuppressWarnings("unchecked") @Override public Map postProcessModels(Map objs) { objs = super.postProcessModels(objs); List models = (List) objs.get("models"); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - if (additionalProperties.containsKey(SERIALIZATION_LIBRARY_JACKSON) && !JERSEY1.equals(getLibrary())) { List> imports = (List>) objs.get("imports"); for (Object _mo : models) { @@ -794,7 +792,6 @@ public Map postProcessModels(Map objs) { boolean isOptionalNullable = Boolean.FALSE.equals(var.required) && Boolean.TRUE.equals(var.isNullable); // only add JsonNullable and related imports to optional and nullable values addImports |= isOptionalNullable; - var.getVendorExtensions().put("isJacksonOptionalNullable", isOptionalNullable); // TODO: 5.0 Remove var.getVendorExtensions().put("x-is-jackson-optional-nullable", isOptionalNullable); } if (addImports) { @@ -817,10 +814,9 @@ public Map postProcessModels(Map objs) { for (Object _mo : models) { Map mo = (Map) _mo; CodegenModel cm = (CodegenModel) mo.get("model"); - cm.getVendorExtensions().putIfAbsent("implements", new ArrayList()); // TODO: 5.0 Remove - cm.getVendorExtensions().putIfAbsent("x-implements", cm.getVendorExtensions().get("implements")); - //List impl = (List) cm.getVendorExtensions().get("x-implements"); - if (JERSEY2.equals(getLibrary())) { + + cm.getVendorExtensions().putIfAbsent("x-implements", new ArrayList()); + if (JERSEY2_EXPERIMENTAL.equals(getLibrary())) { cm.getVendorExtensions().put("x-implements", new ArrayList()); if (cm.oneOf != null && !cm.oneOf.isEmpty() && cm.oneOf.contains("ModelNull")) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java index fb6b93472dc8..1cfd2e63ad93 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaPlayFrameworkCodegen.java @@ -291,9 +291,6 @@ public void setUseSwaggerUI(boolean useSwaggerUI) { public Map postProcessOperationsWithModels(Map objs, List allModels) { Map operations = (Map) objs.get("operations"); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - if (operations != null) { List ops = (List) operations.get("operation"); for (CodegenOperation operation : ops) { @@ -320,11 +317,9 @@ public Map postProcessOperationsWithModels(Map o if (operation.returnType != null) { if (operation.returnType.equals("Boolean")) { - operation.vendorExtensions.put("missingReturnInfoIfNeeded", "true"); // TODO: 5.0 Remove operation.vendorExtensions.put("x-missing-return-info-if-needed", "true"); } if (operation.returnType.equals("BigDecimal")) { - operation.vendorExtensions.put("missingReturnInfoIfNeeded", "1.0"); // TODO: 5.0 Remove operation.vendorExtensions.put("x-missing-return-info-if-needed", "1.0"); } if (operation.returnType.startsWith("List")) { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java index 6103ae1edc93..a00548c8a844 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptApolloClientCodegen.java @@ -814,9 +814,6 @@ public String toOperationId(String operationId) { @Override public CodegenModel fromModel(String name, Schema model) { - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - Map allDefinitions = ModelUtils.getSchemas(this.openAPI); CodegenModel codegenModel = super.fromModel(name, model); @@ -829,22 +826,17 @@ public CodegenModel fromModel(String name, Schema model) { ArraySchema am = (ArraySchema) model; if (codegenModel != null && am.getItems() != null) { String itemType = getSchemaType(am.getItems()); - codegenModel.vendorExtensions.put("x-isArray", true); // TODO: 5.0 Remove codegenModel.vendorExtensions.put("x-is-array", true); - codegenModel.vendorExtensions.put("x-itemType", itemType); // TODO: 5.0 Remove codegenModel.vendorExtensions.put("x-item-type", itemType); } } else if (ModelUtils.isMapSchema(model)) { if (codegenModel != null && ModelUtils.getAdditionalProperties(model) != null) { String itemType = getSchemaType(ModelUtils.getAdditionalProperties(model)); - codegenModel.vendorExtensions.put("x-isMap", true); // TODO: 5.0 Remove codegenModel.vendorExtensions.put("x-is-map", true); - codegenModel.vendorExtensions.put("x-itemType", itemType); // TODO: 5.0 Remove codegenModel.vendorExtensions.put("x-item-type", itemType); } else { String type = model.getType(); if (codegenModel != null && isPrimitiveType(type)) { - codegenModel.vendorExtensions.put("x-isPrimitive", true); // TODO: 5.0 Remove codegenModel.vendorExtensions.put("x-is-primitive", true); } } @@ -918,9 +910,6 @@ public Map postProcessOperationsWithModels(Map o // vendor-extension: x-codegen-argList. Map operations = (Map) objs.get("operations"); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - if (operations != null) { List ops = (List) operations.get("operation"); for (CodegenOperation operation : ops) { @@ -944,9 +933,7 @@ public Map postProcessOperationsWithModels(Map o } String joinedArgList = StringUtils.join(argList, ", "); - operation.vendorExtensions.put("x-codegen-argList", joinedArgList); // TODO: 5.0 Remove operation.vendorExtensions.put("x-codegen-arg-list", joinedArgList); - operation.vendorExtensions.put("x-codegen-hasOptionalParams", hasOptionalParams); // TODO: 5.0 Remove operation.vendorExtensions.put("x-codegen-has-optional-params", hasOptionalParams); // Store JSDoc type specification into vendor-extension: x-jsdoc-type. @@ -972,9 +959,6 @@ public Map postProcessModels(Map objs) { objs = super.postProcessModelsEnum(objs); List models = (List) objs.get("models"); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (Object _mo : models) { Map mo = (Map) _mo; CodegenModel cm = (CodegenModel) mo.get("model"); @@ -1025,10 +1009,8 @@ public Map postProcessModels(Map objs) { for (CodegenProperty var : cm.vars) { Optional.ofNullable(lastRequired).ifPresent(_lastRequired -> { if (var == _lastRequired) { - var.vendorExtensions.put("x-codegen-hasMoreRequired", false); // TODO: 5.0 Remove var.vendorExtensions.put("x-codegen-has-more-required", false); } else if (var.required) { - var.vendorExtensions.put("x-codegen-hasMoreRequired", true); // TODO: 5.0 Remove var.vendorExtensions.put("x-codegen-has-more-required", true); } }); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java index 2beed8ba2f4a..a9eb57555cbb 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavascriptClientCodegen.java @@ -860,9 +860,6 @@ public String toOperationId(String operationId) { @Override public CodegenModel fromModel(String name, Schema model) { - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - Map allDefinitions = ModelUtils.getSchemas(this.openAPI); CodegenModel codegenModel = super.fromModel(name, model); @@ -875,22 +872,17 @@ public CodegenModel fromModel(String name, Schema model) { ArraySchema am = (ArraySchema) model; if (codegenModel != null && am.getItems() != null) { String itemType = getSchemaType(am.getItems()); - codegenModel.vendorExtensions.put("x-isArray", true); // TODO: 5.0 Remove codegenModel.vendorExtensions.put("x-is-array", true); - codegenModel.vendorExtensions.put("x-itemType", itemType); // TODO: 5.0 Remove codegenModel.vendorExtensions.put("x-item-type", itemType); } } else if (ModelUtils.isMapSchema(model)) { if (codegenModel != null && ModelUtils.getAdditionalProperties(model) != null) { String itemType = getSchemaType(ModelUtils.getAdditionalProperties(model)); - codegenModel.vendorExtensions.put("x-isMap", true); // TODO: 5.0 Remove codegenModel.vendorExtensions.put("x-is-map", true); - codegenModel.vendorExtensions.put("x-itemType", itemType); // TODO: 5.0 Remove codegenModel.vendorExtensions.put("x-item-type", itemType); } else { String type = model.getType(); if (codegenModel != null && isPrimitiveType(type)) { - codegenModel.vendorExtensions.put("x-isPrimitive", true); // TODO: 5.0 Remove codegenModel.vendorExtensions.put("x-is-primitive", true); } } @@ -990,9 +982,6 @@ public Map postProcessOperationsWithModels(Map o // vendor-extension: x-codegen-argList. Map operations = (Map) objs.get("operations"); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - if (operations != null) { List ops = (List) operations.get("operation"); for (CodegenOperation operation : ops) { @@ -1019,9 +1008,7 @@ public Map postProcessOperationsWithModels(Map o argList.add("callback"); } String joinedArgList = StringUtils.join(argList, ", "); - operation.vendorExtensions.put("x-codegen-argList", joinedArgList); // TODO: 5.0 Remove operation.vendorExtensions.put("x-codegen-arg-list", joinedArgList); - operation.vendorExtensions.put("x-codegen-hasOptionalParams", hasOptionalParams); // TODO: 5.0 Remove operation.vendorExtensions.put("x-codegen-has-optional-params", hasOptionalParams); // Store JSDoc type specification into vendor-extension: x-jsdoc-type. @@ -1047,9 +1034,6 @@ public Map postProcessModels(Map objs) { objs = super.postProcessModelsEnum(objs); List models = (List) objs.get("models"); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (Object _mo : models) { Map mo = (Map) _mo; CodegenModel cm = (CodegenModel) mo.get("model"); @@ -1100,10 +1084,8 @@ public Map postProcessModels(Map objs) { for (CodegenProperty var : cm.vars) { Optional.ofNullable(lastRequired).ifPresent(_lastRequired -> { if (var == _lastRequired) { - var.vendorExtensions.put("x-codegen-hasMoreRequired", false); // TODO: 5.0 Remove var.vendorExtensions.put("x-codegen-has-more-required", false); } else if (var.required) { - var.vendorExtensions.put("x-codegen-hasMoreRequired", true); // TODO: 5.0 Remove var.vendorExtensions.put("x-codegen-has-more-required", true); } }); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MysqlSchemaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MysqlSchemaCodegen.java index 334f9579aed0..a0dca282ea65 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MysqlSchemaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/MysqlSchemaCodegen.java @@ -29,10 +29,10 @@ import static org.openapitools.codegen.utils.StringUtils.underscore; +@SuppressWarnings("unchecked") public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig { private static final Logger LOGGER = LoggerFactory.getLogger(MysqlSchemaCodegen.class); - public static final String CODEGEN_VENDOR_EXTENSION_KEY = "x-mysqlSchema"; // TODO: 5.0 Remove public static final String VENDOR_EXTENSION_MYSQL_SCHEMA = "x-mysql-schema"; public static final String DEFAULT_DATABASE_NAME = "defaultDatabaseName"; public static final String JSON_DATA_TYPE_ENABLED = "jsonDataTypeEnabled"; @@ -271,12 +271,11 @@ public Map postProcessModels(Map objs) { modelDescription = (modelDescription == null || modelDescription.isEmpty()) ? commentExtra : modelDescription + ". " + commentExtra; } - if (modelVendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) { + if (modelVendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) { // user already specified schema values LOGGER.info("Found vendor extension in '" + modelName + "' model, autogeneration skipped"); - continue; } else { - modelVendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); + modelVendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema); mysqlSchema.put("tableDefinition", tableDefinition); tableDefinition.put("tblName", tableName); tableDefinition.put("tblComment", modelDescription); @@ -335,15 +334,15 @@ public void processIntegerTypeProperty(CodegenModel model, CodegenProperty prope String description = property.getDescription(); String minimum = property.getMinimum(); String maximum = property.getMaximum(); - Boolean exclusiveMinimum = property.getExclusiveMinimum(); - Boolean exclusiveMaximum = property.getIExclusiveMaximum(); + boolean exclusiveMinimum = property.getExclusiveMinimum(); + boolean exclusiveMaximum = property.getIExclusiveMaximum(); String defaultValue = property.getDefaultValue(); Boolean required = property.getRequired(); - Boolean unsigned = false; + boolean unsigned = false; Boolean isUuid = property.isUuid; Boolean isEnum = property.isEnum; - if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) { + if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) { // user already specified schema values LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped"); return; @@ -355,7 +354,6 @@ public void processIntegerTypeProperty(CodegenModel model, CodegenProperty prope description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra; } - vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema); mysqlSchema.put("columnDefinition", columnDefinition); columnDefinition.put("colName", colName); @@ -363,7 +361,7 @@ public void processIntegerTypeProperty(CodegenModel model, CodegenProperty prope if (Boolean.TRUE.equals(isEnum)) { Map allowableValues = property.getAllowableValues(); List enumValues = (List) allowableValues.get("values"); - for (Integer i = 0; i < enumValues.size(); i++) { + for (int i = 0; i < enumValues.size(); i++) { if (i > ENUM_MAX_ELEMENTS - 1) { LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i)); break; @@ -379,8 +377,8 @@ public void processIntegerTypeProperty(CodegenModel model, CodegenProperty prope } else { Long min = (minimum != null) ? Long.parseLong(minimum) : null; Long max = (maximum != null) ? Long.parseLong(maximum) : null; - if (exclusiveMinimum == true && min != null) min += 1; - if (exclusiveMaximum == true && max != null) max -= 1; + if (exclusiveMinimum && min != null) min += 1; + if (exclusiveMaximum && max != null) max -= 1; if (min != null && min >= 0) { unsigned = true; } @@ -424,14 +422,14 @@ public void processDecimalTypeProperty(CodegenModel model, CodegenProperty prope String description = property.getDescription(); String minimum = property.getMinimum(); String maximum = property.getMaximum(); - Boolean exclusiveMinimum = property.getExclusiveMinimum(); - Boolean exclusiveMaximum = property.getIExclusiveMaximum(); + boolean exclusiveMinimum = property.getExclusiveMinimum(); + boolean exclusiveMaximum = property.getIExclusiveMaximum(); String defaultValue = property.getDefaultValue(); Boolean required = property.getRequired(); - Boolean unsigned = false; + boolean unsigned = false; Boolean isEnum = property.isEnum; - if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) { + if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) { // user already specified schema values LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped"); return; @@ -443,7 +441,6 @@ public void processDecimalTypeProperty(CodegenModel model, CodegenProperty prope description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra; } - vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema); mysqlSchema.put("columnDefinition", columnDefinition); columnDefinition.put("colName", colName); @@ -451,7 +448,7 @@ public void processDecimalTypeProperty(CodegenModel model, CodegenProperty prope if (Boolean.TRUE.equals(isEnum)) { Map allowableValues = property.getAllowableValues(); List enumValues = (List) allowableValues.get("values"); - for (Integer i = 0; i < enumValues.size(); i++) { + for (int i = 0; i < enumValues.size(); i++) { if (i > ENUM_MAX_ELEMENTS - 1) { LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i)); break; @@ -464,8 +461,8 @@ public void processDecimalTypeProperty(CodegenModel model, CodegenProperty prope } else { Float min = (minimum != null) ? Float.valueOf(minimum) : null; Float max = (maximum != null) ? Float.valueOf(maximum) : null; - if (exclusiveMinimum == true && min != null) min += 1; - if (exclusiveMaximum == true && max != null) max -= 1; + if (exclusiveMinimum && min != null) min += 1; + if (exclusiveMaximum && max != null) max -= 1; if (min != null && min >= 0) { unsigned = true; } @@ -510,7 +507,7 @@ public void processBooleanTypeProperty(CodegenModel model, CodegenProperty prope String defaultValue = property.getDefaultValue(); Boolean required = property.getRequired(); - if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) { + if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) { // user already specified schema values LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped"); return; @@ -522,7 +519,6 @@ public void processBooleanTypeProperty(CodegenModel model, CodegenProperty prope description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra; } - vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema); mysqlSchema.put("columnDefinition", columnDefinition); columnDefinition.put("colName", colName); @@ -569,7 +565,7 @@ public void processStringTypeProperty(CodegenModel model, CodegenProperty proper Boolean required = property.getRequired(); Boolean isEnum = property.isEnum; - if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) { + if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) { // user already specified schema values LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped"); return; @@ -581,7 +577,6 @@ public void processStringTypeProperty(CodegenModel model, CodegenProperty proper description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra; } - vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema); mysqlSchema.put("columnDefinition", columnDefinition); columnDefinition.put("colName", colName); @@ -591,7 +586,7 @@ public void processStringTypeProperty(CodegenModel model, CodegenProperty proper List enumValues = (List) allowableValues.get("values"); columnDefinition.put("colDataType", "ENUM"); columnDefinition.put("colDataTypeArguments", columnDataTypeArguments); - for (Integer i = 0; i < enumValues.size(); i++) { + for (int i = 0; i < enumValues.size(); i++) { if (i > ENUM_MAX_ELEMENTS - 1) { LOGGER.warn("ENUM column can have maximum of " + ENUM_MAX_ELEMENTS.toString() + " distinct elements, following value will be skipped: " + (String) enumValues.get(i)); break; @@ -644,7 +639,7 @@ public void processDateTypeProperty(CodegenModel model, CodegenProperty property String description = property.getDescription(); String defaultValue = property.getDefaultValue(); - if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) { + if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) { // user already specified schema values LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped"); return; @@ -656,7 +651,6 @@ public void processDateTypeProperty(CodegenModel model, CodegenProperty property description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra; } - vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema); mysqlSchema.put("columnDefinition", columnDefinition); columnDefinition.put("colName", colName); @@ -696,7 +690,7 @@ public void processJsonTypeProperty(CodegenModel model, CodegenProperty property String description = property.getDescription(); String defaultValue = property.getDefaultValue(); - if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) { + if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) { // user already specified schema values LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped"); return; @@ -708,7 +702,6 @@ public void processJsonTypeProperty(CodegenModel model, CodegenProperty property description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra; } - vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema); mysqlSchema.put("columnDefinition", columnDefinition); columnDefinition.put("colName", colName); @@ -751,7 +744,7 @@ public void processUnknownTypeProperty(CodegenModel model, CodegenProperty prope String description = property.getDescription(); String defaultValue = property.getDefaultValue(); - if (vendorExtensions.containsKey(CODEGEN_VENDOR_EXTENSION_KEY)) { + if (vendorExtensions.containsKey(VENDOR_EXTENSION_MYSQL_SCHEMA)) { // user already specified schema values LOGGER.info("Found vendor extension in '" + baseName + "' property, autogeneration skipped"); return; @@ -763,7 +756,6 @@ public void processUnknownTypeProperty(CodegenModel model, CodegenProperty prope description = (description == null || description.isEmpty()) ? commentExtra : description + ". " + commentExtra; } - vendorExtensions.put(CODEGEN_VENDOR_EXTENSION_KEY, mysqlSchema); // TODO: 5.0 Remove vendorExtensions.put(VENDOR_EXTENSION_MYSQL_SCHEMA, mysqlSchema); mysqlSchema.put("columnDefinition", columnDefinition); columnDefinition.put("colName", colName); @@ -902,10 +894,10 @@ public HashMap toCodegenMysqlDataTypeDefault(String defaultValue public String getMysqlMatchedIntegerDataType(Long minimum, Long maximum, Boolean unsigned) { // we can choose fit mysql data type // ref: https://dev.mysql.com/doc/refman/8.0/en/integer-types.html - Long min = (minimum != null) ? minimum : -2147483648L; - Long max = (maximum != null) ? maximum : 2147483647L; - Long actualMin = Math.min(min, max); // sometimes min and max values can be mixed up - Long actualMax = Math.max(min, max); // sometimes only minimum specified and it can be pretty high + long min = (minimum != null) ? minimum : -2147483648L; + long max = (maximum != null) ? maximum : 2147483647L; + long actualMin = Math.min(min, max); // sometimes min and max values can be mixed up + long actualMax = Math.max(min, max); // sometimes only minimum specified and it can be pretty high if (minimum != null && maximum != null && minimum > maximum) { LOGGER.warn("Codegen property 'minimum' cannot be greater than 'maximum'"); } @@ -948,8 +940,8 @@ public String getMysqlMatchedIntegerDataType(Long minimum, Long maximum, Boolean public String getMysqlMatchedStringDataType(Integer minLength, Integer maxLength) { // we can choose fit mysql data type // ref: https://dev.mysql.com/doc/refman/8.0/en/string-type-overview.html - Integer min = (minLength != null && minLength >= 0) ? minLength : 0; - Integer max = (maxLength != null && maxLength >= 0) ? maxLength : 65535; + int min = (minLength != null && minLength >= 0) ? minLength : 0; + int max = (maxLength != null && maxLength >= 0) ? maxLength : 65535; Integer actualMin = Math.min(min, max); // sometimes minLength and maxLength values can be mixed up Integer actualMax = Math.max(min, max); // sometimes only minLength specified and it can be pretty high if (minLength != null && maxLength != null && minLength > maxLength) { @@ -1139,7 +1131,7 @@ public String escapeUnsafeCharacters(String input) { */ public void setDefaultDatabaseName(String databaseName) { String escapedName = toDatabaseName(databaseName); - if (escapedName.equals(databaseName) == false) { + if (!escapedName.equals(databaseName)) { LOGGER.error("Invalid database name. '" + databaseName + "' cannot be used as MySQL identifier. Escaped value '" + escapedName + "' will be used instead."); } this.defaultDatabaseName = escapedName; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java index d3e022bf6d6d..ff447d1b4dff 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java @@ -715,9 +715,6 @@ public Map postProcessOperationsWithModels(Map o @SuppressWarnings("unchecked") List operations = (List) objectMap.get("operation"); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (CodegenOperation operation : operations) { // http method verb conversion, depending on client library (e.g. Hyper: PUT => Put, Reqwest: PUT => put) //if (CO_HTTP.equals(getLibrary())) { @@ -728,7 +725,6 @@ public Map postProcessOperationsWithModels(Map o } if ("Yojson.Safe.t".equals(operation.returnBaseType)) { - operation.vendorExtensions.put("x-returnFreeFormObject", true); // TODO: 5.0 Remove operation.vendorExtensions.put("x-return-free-form-object", true); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java index 2fa81b97dd4e..950aebe9de89 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ObjcClientCodegen.java @@ -654,15 +654,11 @@ public void setLicense(String license) { public Map postProcessOperationsWithModels(Map objs, List allModels) { Map operations = (Map) objs.get("operations"); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - if (operations != null) { List ops = (List) operations.get("operation"); for (CodegenOperation operation : ops) { if (!operation.allParams.isEmpty()) { String firstParamName = operation.allParams.get(0).paramName; - operation.vendorExtensions.put("firstParamAltName", camelize(firstParamName)); // TODO: 5.0 Remove operation.vendorExtensions.put("x-first-param-alt-name", camelize(firstParamName)); } } @@ -673,11 +669,6 @@ public Map postProcessOperationsWithModels(Map o @Override public void postProcessModelProperty(CodegenModel model, CodegenProperty schema) { super.postProcessModelProperty(model, schema); - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - - schema.vendorExtensions.put("x-uppercaseName", camelize(schema.name)); // TODO: 5.0 Remove schema.vendorExtensions.put("x-uppercase-name", camelize(schema.name)); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java index ef09fa0caa13..3c49b10cd929 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpSymfonyServerCodegen.java @@ -388,9 +388,6 @@ public void processOpts() { public Map postProcessOperationsWithModels(Map objs, List allModels) { objs = super.postProcessOperationsWithModels(objs, allModels); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - Map operations = (Map) objs.get("operations"); operations.put("controllerName", toControllerName((String) operations.get("pathPrefix"))); operations.put("symfonyService", toSymfonyService((String) operations.get("pathPrefix"))); @@ -406,20 +403,16 @@ public Map postProcessOperationsWithModels(Map o // to the templating engine String typeHint = getTypeHint(param.dataType); if (!typeHint.isEmpty()) { - param.vendorExtensions.put("x-parameterType", typeHint); // TODO: 5.0 Remove param.vendorExtensions.put("x-parameter-type", typeHint); } if (param.isContainer) { - param.vendorExtensions.put("x-parameterType", getTypeHint(param.dataType + "[]")); // TODO: 5.0 Remove param.vendorExtensions.put("x-parameter-type", getTypeHint(param.dataType + "[]")); } // Create a variable to display the correct data type in comments for interfaces - param.vendorExtensions.put("x-commentType", param.dataType); // TODO: 5.0 Remove param.vendorExtensions.put("x-comment-type", param.dataType); if (param.isContainer) { - param.vendorExtensions.put("x-commentType", param.dataType + "[]"); // TODO: 5.0 Remove param.vendorExtensions.put("x-comment-type", param.dataType + "[]"); } @@ -434,14 +427,11 @@ public Map postProcessOperationsWithModels(Map o // Create a variable to display the correct return type in comments for interfaces if (op.returnType != null) { - op.vendorExtensions.put("x-commentType", op.returnType); // TODO: 5.0 Remove op.vendorExtensions.put("x-comment-type", op.returnType); if (op.returnContainer != null && op.returnContainer.equals("array")) { - op.vendorExtensions.put("x-commentType", op.returnType + "[]"); // TODO: 5.0 Remove op.vendorExtensions.put("x-comment-type", op.returnType + "[]"); } } else { - op.vendorExtensions.put("x-commentType", "void"); // TODO: 5.0 Remove op.vendorExtensions.put("x-comment-type", "void"); } @@ -464,9 +454,6 @@ public Map postProcessOperationsWithModels(Map o public Map postProcessModels(Map objs) { objs = super.postProcessModels(objs); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - ArrayList modelsArray = (ArrayList) objs.get("models"); Map models = (Map) modelsArray.get(0); CodegenModel model = (CodegenModel) models.get("model"); @@ -478,20 +465,16 @@ public Map postProcessModels(Map objs) { // to the templating engine String typeHint = getTypeHint(var.dataType); if (!typeHint.isEmpty()) { - var.vendorExtensions.put("x-parameterType", typeHint); // TODO: 5.0 Remove var.vendorExtensions.put("x-parameter-type", typeHint); } if (var.isContainer) { - var.vendorExtensions.put("x-parameterType", getTypeHint(var.dataType + "[]")); // TODO: 5.0 Remove var.vendorExtensions.put("x-parameter-type", getTypeHint(var.dataType + "[]")); } // Create a variable to display the correct data type in comments for models - var.vendorExtensions.put("x-commentType", var.dataType); // TODO: 5.0 Remove var.vendorExtensions.put("x-comment-type", var.dataType); if (var.isContainer) { - var.vendorExtensions.put("x-commentType", var.dataType + "[]"); // TODO: 5.0 Remove var.vendorExtensions.put("x-comment-type", var.dataType + "[]"); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java index 706083b50dc4..2db7430b0959 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustClientCodegen.java @@ -195,9 +195,6 @@ public Map postProcessAllModels(Map objs) { // Index all CodegenModels by model name. Map allModels = new HashMap<>(); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (Map.Entry entry : objs.entrySet()) { String modelName = toModelName(entry.getKey()); Map inner = (Map) entry.getValue(); @@ -226,9 +223,7 @@ public Map postProcessAllModels(Map objs) { } // TODO: figure out how to properly have the original property type that didn't go through toVarName String vendorExtensionTagName = cm.discriminator.getPropertyName().replace("_", ""); - cm.vendorExtensions.put("tagName", vendorExtensionTagName); // TODO: 5.0 Remove cm.vendorExtensions.put("x-tag-name", vendorExtensionTagName); - cm.vendorExtensions.put("mappedModels", discriminatorVars); // TODO: 5.0 Remove cm.vendorExtensions.put("x-mapped-models", discriminatorVars); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java index a0ef19a483ad..3ee9f53c48f2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java @@ -609,9 +609,6 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation Map definitions = ModelUtils.getSchemas(this.openAPI); CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - String pathFormatString = op.path; for (CodegenParameter param : op.pathParams) { // Replace {baseName} with {paramName} for format string @@ -735,28 +732,20 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation } String underscoredOperationId = underscore(op.operationId); - op.vendorExtensions.put("operation_id", underscoredOperationId); // TODO: 5.0 Remove op.vendorExtensions.put("x-operation-id", underscoredOperationId); - op.vendorExtensions.put("uppercase_operation_id", underscoredOperationId.toUpperCase(Locale.ROOT)); // TODO: 5.0 Remove op.vendorExtensions.put("x-uppercase-operation-id", underscoredOperationId.toUpperCase(Locale.ROOT)); String vendorExtensionPath = op.path.replace("{", ":").replace("}", ""); - op.vendorExtensions.put("path", vendorExtensionPath); // TODO: 5.0 Remove op.vendorExtensions.put("x-path",vendorExtensionPath); - op.vendorExtensions.put("PATH_ID", pathId); // TODO: 5.0 Remove op.vendorExtensions.put("x-path-id", pathId); - op.vendorExtensions.put("hasPathParams", !op.pathParams.isEmpty()); // TODO: 5.0 Remove op.vendorExtensions.put("x-has-path-params", !op.pathParams.isEmpty()); - op.vendorExtensions.put("hasPathParams", hasPathParams); // TODO: 5.0 Remove op.vendorExtensions.put("x-path-format-string", formatPath); String vendorExtensionHttpMethod = op.httpMethod.toUpperCase(Locale.ROOT); - op.vendorExtensions.put("HttpMethod", vendorExtensionHttpMethod); // TODO: 5.0 Remove op.vendorExtensions.put("x-http-method", vendorExtensionHttpMethod); - // TODO: 5.0 Fix formatting - if (!op.vendorExtensions.containsKey("x-mustUseResponse")) { + if (!op.vendorExtensions.containsKey("x-must-use-response")) { // If there's more than one response, than by default the user must explicitly handle them - op.vendorExtensions.put("x-mustUseResponse", op.responses.size() > 1); + op.vendorExtensions.put("x-must-use-response", op.responses.size() > 1); } for (CodegenParameter param : op.allParams) { @@ -800,7 +789,6 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation processParam(param, op); // Give header params a name in camel case. CodegenParameters don't have a nameInCamelCase property. - param.vendorExtensions.put("typeName", toModelName(param.baseName)); // TODO: 5.0 Remove param.vendorExtensions.put("x-type-name", toModelName(param.baseName)); } @@ -822,9 +810,9 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation // Create a unique responseID for this response. String responseId; - if (rsp.vendorExtensions.containsKey("x-responseId")) { + if (rsp.vendorExtensions.containsKey("x-response-id")) { // If it's been specified directly, use that. - responseId = (String) rsp.vendorExtensions.get("x-responseId"); + responseId = (String) rsp.vendorExtensions.get("x-response-id"); } else if ((words.length != 0) && (words[0].trim().length() != 0)) { // If there's a description, build it from the description. responseId = camelize(words[0].replace(" ", "_")); @@ -850,15 +838,11 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation responseIds.add(responseId); String underscoredResponseId = underscore(responseId).toUpperCase(Locale.ROOT); - rsp.vendorExtensions.put("x-responseId", responseId); // TODO: 5.0 Remove rsp.vendorExtensions.put("x-response-id", responseId); - rsp.vendorExtensions.put("x-uppercaseResponseId", underscoredResponseId.toUpperCase(Locale.ROOT)); // TODO: 5.0 Remove rsp.vendorExtensions.put("x-uppercase-response-id", underscoredResponseId.toUpperCase(Locale.ROOT)); - rsp.vendorExtensions.put("uppercase_operation_id", underscoredOperationId.toUpperCase(Locale.ROOT)); // TODO: 5.0 Remove rsp.vendorExtensions.put("x-uppercase-operation-id", underscoredOperationId.toUpperCase(Locale.ROOT)); if (rsp.dataType != null) { String uppercaseDataType = (rsp.dataType.replace("models::", "")).toUpperCase(Locale.ROOT); - rsp.vendorExtensions.put("uppercase_data_type", uppercaseDataType); // TODO: 5.0 Remove rsp.vendorExtensions.put("x-uppercase-data-type", uppercaseDataType); // Get the mimetype which is produced by this response. Note @@ -908,13 +892,11 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation outputMime = firstProduces; } - rsp.vendorExtensions.put("mimeType", outputMime); // TODO: 5.0 Remove rsp.vendorExtensions.put("x-mime-type", outputMime); // Write out the type of data we actually expect this response // to make. if (producesXml) { - rsp.vendorExtensions.put("producesXml", true); // TODO: 5.0 Remove rsp.vendorExtensions.put("x-produces-xml", true); } else if (producesPlainText) { // Plain text means that there is not structured data in @@ -926,14 +908,11 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation // base64 encoding should be done. They both look like // 'producesBytes'. if (rsp.dataType.equals(bytesType)) { - rsp.vendorExtensions.put("producesBytes", true); // TODO: 5.0 Remove rsp.vendorExtensions.put("x-produces-bytes", true); } else { - rsp.vendorExtensions.put("producesPlainText", true); // TODO: 5.0 Remove rsp.vendorExtensions.put("x-produces-plain-text", true); } } else { - rsp.vendorExtensions.put("producesJson", true); // TODO: 5.0 Remove rsp.vendorExtensions.put("x-produces-json", true); // If the data type is just "object", then ensure that the // Rust data type is "serde_json::Value". This allows us @@ -950,7 +929,6 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation if ((model != null)) { XML xml = model.getXml(); if ((xml != null) && (xml.getNamespace() != null)) { - rsp.vendorExtensions.put("has_namespace", "true"); // TODO: 5.0 Remove rsp.vendorExtensions.put("x-has-namespace", "true"); } } @@ -996,9 +974,6 @@ private void postProcessOperationWithModels(CodegenOperation op, List al boolean consumesPlainText = false; boolean consumesXml = false; - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - if (op.consumes != null) { for (Map consume : op.consumes) { if (consume.get("mediaType") != null) { @@ -1012,7 +987,6 @@ private void postProcessOperationWithModels(CodegenOperation op, List al } else if (isMimetypeWwwFormUrlEncoded(mediaType)) { additionalProperties.put("usesUrlEncodedForm", true); } else if (isMimetypeMultipartFormData(mediaType)) { - op.vendorExtensions.put("consumesMultipart", true); // TODO Remove: 5.0 Remove op.vendorExtensions.put("x-consumes-multipart", true); additionalProperties.put("apiUsesMultipartFormData", true); additionalProperties.put("apiUsesMultipart", true); @@ -1028,16 +1002,12 @@ private void postProcessOperationWithModels(CodegenOperation op, List al String underscoredOperationId = underscore(op.operationId).toUpperCase(Locale.ROOT); if (op.bodyParam != null) { // Default to consuming json - op.bodyParam.vendorExtensions.put("uppercase_operation_id", underscoredOperationId); // TODO: 5.0 Remove op.bodyParam.vendorExtensions.put("x-uppercase-operation-id", underscoredOperationId); if (consumesXml) { - op.bodyParam.vendorExtensions.put("consumesXml", true); // TODO: 5.0 Remove op.bodyParam.vendorExtensions.put("x-consumes-xml", true); } else if (consumesPlainText) { - op.bodyParam.vendorExtensions.put("consumesPlainText", true); // TODO: 5.0 Remove op.bodyParam.vendorExtensions.put("x-consumes-plain-text", true); } else { - op.bodyParam.vendorExtensions.put("consumesJson", true); // TODO: 5.0 Remove op.bodyParam.vendorExtensions.put("x-consumes-json", true); } } @@ -1045,18 +1015,14 @@ private void postProcessOperationWithModels(CodegenOperation op, List al for (CodegenParameter param : op.bodyParams) { processParam(param, op); - param.vendorExtensions.put("uppercase_operation_id", underscoredOperationId); // TODO: 5.0 Remove param.vendorExtensions.put("x-uppercase-operation-id", underscoredOperationId); // Default to producing json if nothing else is specified if (consumesXml) { - param.vendorExtensions.put("consumesXml", true); // TODO: 5.0 Remove param.vendorExtensions.put("x-consumes-xml", true); } else if (consumesPlainText) { - param.vendorExtensions.put("consumesPlainText", true); // TODO: 5.0 Remove param.vendorExtensions.put("x-consumes-plain-text", true); } else { - param.vendorExtensions.put("consumesJson", true); // TODO: 5.0 Remove param.vendorExtensions.put("x-consumes-json", true); } } @@ -1082,7 +1048,6 @@ private void postProcessOperationWithModels(CodegenOperation op, List al for (CodegenSecurity s : op.authMethods) { if (s.isApiKey && s.isKeyInHeader) { - s.vendorExtensions.put("x-apiKeyName", toModelName(s.keyParamName)); // TODO: 5.0 Remove s.vendorExtensions.put("x-api-key-name", toModelName(s.keyParamName)); headerAuthMethods = true; } @@ -1093,7 +1058,6 @@ private void postProcessOperationWithModels(CodegenOperation op, List al } if (headerAuthMethods) { - op.vendorExtensions.put("hasHeaderAuthMethods", "true"); // TODO: 5.0 Remove op.vendorExtensions.put("x-has-header-auth-methods", "true"); } } @@ -1220,13 +1184,8 @@ public String toInstantiationType(Schema p) { @Override public CodegenModel fromModel(String name, Schema model) { - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - Map allDefinitions = ModelUtils.getSchemas(this.openAPI); CodegenModel mdl = super.fromModel(name, model); - mdl.vendorExtensions.put("upperCaseName", name.toUpperCase(Locale.ROOT)); // TODO: 5.0 Remove mdl.vendorExtensions.put("x-upper-case-name", name.toUpperCase(Locale.ROOT)); if (!StringUtils.isEmpty(model.get$ref())) { Schema schema = allDefinitions.get(ModelUtils.getSimpleRef(model.get$ref())); @@ -1258,7 +1217,6 @@ public CodegenModel fromModel(String name, Schema model) { // If this model's items require wrapping in xml, squirrel away the // xml name so we can insert it into the relevant model fields. if (xmlName != null) { - mdl.vendorExtensions.put("itemXmlName", xmlName); // TODO: 5.0 Remove mdl.vendorExtensions.put("x-item-xml-name", xmlName); modelXmlNames.put("models::" + mdl.classname, xmlName); } @@ -1287,9 +1245,6 @@ public CodegenModel fromModel(String name, Schema model) { public Map postProcessAllModels(Map objs) { Map newObjs = super.postProcessAllModels(objs); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - //Index all CodegenModels by model name. HashMap allModels = new HashMap(); for (Entry entry : objs.entrySet()) { @@ -1317,7 +1272,6 @@ public Map postProcessAllModels(Map objs) { String xmlName = modelXmlNames.get(prop.dataType); if (xmlName != null) { - prop.vendorExtensions.put("itemXmlName", xmlName); // TODO: 5.0 Remove prop.vendorExtensions.put("x-item-xml-name", xmlName); } @@ -1564,9 +1518,6 @@ private String matchingIntType(boolean unsigned, Long inclusiveMin, Long inclusi public Map postProcessModels(Map objs) { List models = (List) objs.get("models"); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (Object _mo : models) { Map mo = (Map) _mo; CodegenModel cm = (CodegenModel) mo.get("model"); @@ -1608,7 +1559,6 @@ public Map postProcessModels(Map objs) { } } - cm.vendorExtensions.put("isString", "String".equals(cm.dataType)); // TODO: 5.0 Remove cm.vendorExtensions.put("x-is-string", "String".equals(cm.dataType)); } return super.postProcessModelsEnum(objs); @@ -1618,9 +1568,6 @@ private void processParam(CodegenParameter param, CodegenOperation op) { String example = null; - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - // If a parameter uses UUIDs, we need to import the UUID package. if (uuidType.equals(param.dataType)) { additionalProperties.put("apiUsesUuid", true); @@ -1630,26 +1577,20 @@ private void processParam(CodegenParameter param, CodegenOperation op) { param.vendorExtensions.put("formatString", "{:?}"); example = null; } else if (param.isString) { - param.vendorExtensions.put("formatString", "\\\"{}\\\""); // TODO: 5.0 Remove - param.vendorExtensions.put("x-format-string", "\\\"{}\\\""); // TODO: 5.0 Remove example = "\"" + ((param.example != null) ? param.example : "") + "\".to_string()"; } else if (param.isPrimitiveType) { if ((param.isByteArray) || (param.isBinary)) { // Binary primitive types don't implement `Display`. - param.vendorExtensions.put("formatString", "{:?}"); // TODO: 5.0 Remove param.vendorExtensions.put("x-format-string", "{:?}"); example = "swagger::ByteArray(Vec::from(\"" + ((param.example != null) ? param.example : "") + "\"))"; } else { - param.vendorExtensions.put("formatString", "{}"); // TODO: 5.0 Remove param.vendorExtensions.put("x-format-string", "{}"); example = (param.example != null) ? param.example : ""; } } else if (param.isListContainer) { - param.vendorExtensions.put("formatString", "{:?}"); // TODO: 5.0 Remove param.vendorExtensions.put("x-format-string", "{:?}"); example = (param.example != null) ? param.example : "&Vec::new()"; } else { - param.vendorExtensions.put("formatString", "{:?}"); // TODO: 5.0 Remove param.vendorExtensions.put("x-format-string", "{:?}"); if (param.example != null) { example = "serde_json::from_str::<" + param.dataType + ">(r#\"" + param.example + "\"#).expect(\"Failed to parse JSON example\")"; @@ -1658,30 +1599,22 @@ private void processParam(CodegenParameter param, CodegenOperation op) { if (param.required) { if (example != null) { - param.vendorExtensions.put("example", example); // TODO: 5.0 Remove param.vendorExtensions.put("x-example", example); } else if (param.isListContainer) { // Use the empty list if we don't have an example - param.vendorExtensions.put("example", "&Vec::new()"); // TODO: 5.0 Remove param.vendorExtensions.put("x-example", "&Vec::new()"); } else { // If we don't have an example that we can provide, we need to disable the client example, as it won't build. - param.vendorExtensions.put("example", "???"); // TODO: 5.0 Remove param.vendorExtensions.put("x-example", "???"); - op.vendorExtensions.put("noClientExample", Boolean.TRUE); // TODO: 5.0 Remove op.vendorExtensions.put("x-no-client-example", Boolean.TRUE); } } else if ((param.dataFormat != null) && ((param.dataFormat.equals("date-time")) || (param.dataFormat.equals("date")))) { - param.vendorExtensions.put("formatString", "{:?}"); // TODO: 5.0 Remove param.vendorExtensions.put("x-format-string", "{:?}"); - param.vendorExtensions.put("example", "None"); // TODO: 5.0 Remove param.vendorExtensions.put("x-example", "None"); } else { // Not required, so override the format string and example - param.vendorExtensions.put("formatString", "{:?}"); // TODO: 5.0 Remove param.vendorExtensions.put("x-format-string", "{:?}"); String exampleString = (example != null) ? "Some(" + example + ")" : "None"; - param.vendorExtensions.put("example", exampleString); // TODO: 5.0 Remove param.vendorExtensions.put("x-example", exampleString); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaFinchServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaFinchServerCodegen.java index d49f37e56225..e3e9c4f419eb 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaFinchServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaFinchServerCodegen.java @@ -346,9 +346,6 @@ private void authParameters(CodegenOperation op) { String authInputParams = ""; String typedAuthInputParams = ""; - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - //Append apikey security to path params and create input parameters for functions if (op.authMethods != null) { @@ -365,10 +362,6 @@ private void authParameters(CodegenOperation op) { } } - op.vendorExtensions.put("x-codegen-authParams", authParams); // TODO: 5.0 Remove - op.vendorExtensions.put("x-codegen-authInputParams", authInputParams); // TODO: 5.0 Remove - op.vendorExtensions.put("x-codegen-typedAuthInputParams", typedAuthInputParams); // TODO: 5.0 Remove - op.vendorExtensions.put("x-codegen-auth-params", authParams); op.vendorExtensions.put("x-codegen-auth-input-params", authInputParams); op.vendorExtensions.put("x-codegen-typed-auth-input-params", typedAuthInputParams); @@ -414,10 +407,6 @@ private void generateScalaPath(CodegenOperation op) { private void concatParameters(CodegenOperation op) { - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - String path = colConcat(colConcat(op.vendorExtensions.get("x-codegen-path").toString(), op.vendorExtensions.get("x-codegen-pathParams").toString()), op.vendorExtensions.get("x-codegen-authParams").toString()); String parameters = csvConcat(op.vendorExtensions.get("x-codegen-inputParams").toString(), op.vendorExtensions.get("x-codegen-authInputParams").toString()); String typedParameters = csvConcat(op.vendorExtensions.get("x-codegen-typedInputParams").toString(), op.vendorExtensions.get("x-codegen-typedAuthInputParams").toString()); @@ -425,7 +414,6 @@ private void concatParameters(CodegenOperation op) { // The input parameters for functions op.vendorExtensions.put("x-codegen-paths", path); op.vendorExtensions.put("x-codegen-params", parameters); - op.vendorExtensions.put("x-codegen-typedParams", typedParameters); // TODO: 5.0 Remove op.vendorExtensions.put("x-codegen-typed-params", typedParameters); } @@ -433,9 +421,6 @@ private void concatParameters(CodegenOperation op) { private void generateInputParameters(CodegenOperation op) { - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - String inputParams = ""; String typedInputParams = ""; String pathParams = ""; @@ -482,13 +467,10 @@ private void generateInputParameters(CodegenOperation op) { } // All body, path, query and header parameters - op.vendorExtensions.put("x-codegen-pathParams", pathParams); // TODO: 5.0 Remove op.vendorExtensions.put("x-codegen-path-params", pathParams); // The input parameters for functions - op.vendorExtensions.put("x-codegen-inputParams", inputParams); // TODO: 5.0 Remove op.vendorExtensions.put("x-codegen-input-params", inputParams); - op.vendorExtensions.put("x-codegen-typedInputParams", typedInputParams); // TODO: 5.0 Remove op.vendorExtensions.put("x-codegen-typed-input-params", typedInputParams); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaPlayFrameworkServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaPlayFrameworkServerCodegen.java index 4c1da136a2e4..3d81d2da33cb 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaPlayFrameworkServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaPlayFrameworkServerCodegen.java @@ -258,9 +258,6 @@ public Map postProcessAllModels(Map objs) { objs = super.postProcessAllModels(objs); Map modelsByClassName = new HashMap<>(); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (Object _outer : objs.values()) { Map outer = (Map) _outer; List> models = (List>) outer.get("models"); @@ -271,7 +268,6 @@ public Map postProcessAllModels(Map objs) { cm.classVarName = camelize(cm.classVarName, true); modelsByClassName.put(cm.classname, cm); boolean hasFiles = cm.vars.stream().anyMatch(var -> var.isFile); - cm.vendorExtensions.put("hasFiles", hasFiles); // TODO: 5.0 Remove cm.vendorExtensions.put("x-has-files", hasFiles); } } @@ -289,9 +285,6 @@ public Map postProcessSupportingFileData(Map obj objs = super.postProcessSupportingFileData(objs); generateJSONSpecFile(objs); - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - // Prettify routes file Map apiInfo = (Map) objs.get("apiInfo"); List> apis = (List>) apiInfo.get("apis"); @@ -304,11 +297,9 @@ public Map postProcessSupportingFileData(Map obj .reduce(0, Integer::max); ops.forEach(op -> { String paddedPath = rightPad(op.path, maxPathLength - op.httpMethod.length()); - op.vendorExtensions.put("paddedPath", paddedPath); // TODO: 5.0 Remove op.vendorExtensions.put("x-padded-path", paddedPath); }); ops.forEach(op -> { - op.vendorExtensions.put("hasPathParams", op.getHasPathParams()); // TODO: 5.0 Remove op.vendorExtensions.put("x-has-path-params", op.getHasPathParams()); }); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/StaticHtml2Generator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/StaticHtml2Generator.java index 347b371c7769..54aef3e495e7 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/StaticHtml2Generator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/StaticHtml2Generator.java @@ -202,10 +202,6 @@ public void preprocessOpenAPI(OpenAPI openAPI) { @Override public CodegenOperation fromOperation(String path, String httpMethod, Operation operation, List servers) { CodegenOperation op = super.fromOperation(path, httpMethod, operation, servers); - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - if (op.returnType != null) { op.returnType = normalizeType(op.returnType); } @@ -214,7 +210,6 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation op.path = sanitizePath(op.path); String methodUpperCase = httpMethod.toUpperCase(Locale.ROOT); - op.vendorExtensions.put("x-codegen-httpMethodUpperCase", methodUpperCase); // TODO: 5.0 Remove op.vendorExtensions.put("x-codegen-http-method-upper-case", methodUpperCase); return op; @@ -248,9 +243,6 @@ private void preparHtmlForGlobalDescription(OpenAPI openAPI) { public List postProcessParameterEnum(List parameterList) { String enumFormatted = ""; - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - for (CodegenParameter parameter : parameterList) { if (parameter.isEnum) { for (int i = 0; i < parameter._enum.size(); i++) { @@ -262,7 +254,6 @@ public List postProcessParameterEnum(List pa Markdown markInstance = new Markdown(); if (!enumFormatted.isEmpty()) { String formattedExtension = markInstance.toHtml(enumFormatted); - parameter.vendorExtensions.put("x-eumFormatted", formattedExtension); // TODO: 5.0 Remove parameter.vendorExtensions.put("x-eum-formatted", formattedExtension); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java index 2d00d6b30a01..14ecf6614500 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptRxjsClientCodegen.java @@ -249,11 +249,7 @@ private void updateOperationParameterEnumInformation(Map operati private void setParamNameAlternative(CodegenParameter param, String paramName, String paramNameAlternative) { - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - if (param.paramName.equals(paramName)) { - param.vendorExtensions.put("paramNameAlternative", paramNameAlternative); // TODO: 5.0 Remove param.vendorExtensions.put("x-param-name-alternative", paramNameAlternative); } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/OneOfImplementorAdditionalData.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/OneOfImplementorAdditionalData.java index 3ba31200598c..c0dc9e685063 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/OneOfImplementorAdditionalData.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/OneOfImplementorAdditionalData.java @@ -103,18 +103,13 @@ public void addFromInterfaceModel(CodegenModel cm, List> mod * @param implImports imports of the implementing model * @param addInterfaceImports whether or not to add the interface model as import (will vary by language) */ + @SuppressWarnings("unchecked") public void addToImplementor(CodegenConfig cc, CodegenModel implcm, List> implImports, boolean addInterfaceImports) { - - // TODO: 5.0: Remove the camelCased vendorExtension below and ensure templates use the newer property naming. - once(LOGGER).warn("4.3.0 has deprecated the use of vendor extensions which don't follow lower-kebab casing standards with x- prefix."); - - - implcm.getVendorExtensions().putIfAbsent("implements", new ArrayList()); // TODO: 5.0 Remove - implcm.getVendorExtensions().putIfAbsent("x-implements", implcm.getVendorExtensions().get("implements")); + implcm.getVendorExtensions().putIfAbsent("x-implements", new ArrayList()); // Add implemented interfaces for (String intf : additionalInterfaces) { - List impl = (List) implcm.getVendorExtensions().get("implements"); + List impl = (List) implcm.getVendorExtensions().get("x-implements"); impl.add(intf); if (addInterfaceImports) { // Add imports for interfaces diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/OneOfImplementorAdditionalDataTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/OneOfImplementorAdditionalDataTest.java index 9f8f969b49a2..5a10f3d219d0 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/OneOfImplementorAdditionalDataTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/OneOfImplementorAdditionalDataTest.java @@ -53,7 +53,7 @@ public void testGeneralUsage() { o.addToImplementor(cc, implModel, implModelImports, false); // make sure all the additions were done correctly - Assert.assertEquals(implModel.getVendorExtensions().get("implements"), new ArrayList(){{add(oneOfModel.classname);}}); + Assert.assertEquals(implModel.getVendorExtensions().get("x-implements"), new ArrayList(){{add(oneOfModel.classname);}}); Assert.assertEquals(implModelImports, interfaceModelImports); Assert.assertEquals(implModel.vars, new ArrayList(){{add(cp3); add(cp1);}}); Assert.assertTrue(implModel.vars.get(0).hasMore); From 5e4286885b63066ff43ed712102af4444ae9de47 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sun, 26 Apr 2020 09:43:41 -0400 Subject: [PATCH 02/16] [breaking] Rename system properties to global properties --- .../openapitools/codegen/cmd/Generate.java | 3 +- .../codegen/config/WorkflowSettings.java | 48 ++++++++----------- .../codegen/config/WorkflowSettingsTest.java | 8 ++-- .../README.adoc | 12 ++--- .../samples/local-spec/build.gradle | 4 +- .../gradle/plugin/OpenApiGeneratorPlugin.kt | 2 +- .../OpenApiGeneratorGenerateExtension.kt | 4 +- .../gradle/plugin/tasks/GenerateTask.kt | 17 ++++--- .../codegen/plugin/CodeGenMojo.java | 22 +-------- .../codegen/config/CodegenConfigurator.java | 21 ++++---- .../config/CodegenConfiguratorUtils.java | 35 +------------- .../codegen/AbstractIntegrationTest.java | 4 +- .../config/CodegenConfiguratorTest.java | 3 +- .../src/test/resources/sampleConfig.json | 2 +- 14 files changed, 60 insertions(+), 125 deletions(-) diff --git a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java index 084026f5552e..b7f989eeaacd 100644 --- a/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java +++ b/modules/openapi-generator-cli/src/main/java/org/openapitools/codegen/cmd/Generate.java @@ -71,9 +71,8 @@ public class Generate extends OpenApiGeneratorCommand { + "Pass in a URL-encoded string of name:header with a comma separating multiple values") private String auth; - // TODO: Remove -D short option in 5.0 @Option( - name = {"-D", "--global-property"}, + name = {"--global-property"}, title = "global properties", description = "sets specified global properties (previously called 'system properties') in " + "the format of name=value,name=value (or multiple options, each with name=value)") diff --git a/modules/openapi-generator-core/src/main/java/org/openapitools/codegen/config/WorkflowSettings.java b/modules/openapi-generator-core/src/main/java/org/openapitools/codegen/config/WorkflowSettings.java index 2a0c9ac572af..c7a49db52a73 100644 --- a/modules/openapi-generator-core/src/main/java/org/openapitools/codegen/config/WorkflowSettings.java +++ b/modules/openapi-generator-core/src/main/java/org/openapitools/codegen/config/WorkflowSettings.java @@ -47,7 +47,7 @@ public class WorkflowSettings { public static final boolean DEFAULT_ENABLE_MINIMAL_UPDATE = false; public static final boolean DEFAULT_STRICT_SPEC_BEHAVIOR = true; public static final String DEFAULT_TEMPLATING_ENGINE_NAME = "mustache"; - public static final ImmutableMap DEFAULT_SYSTEM_PROPERTIES = ImmutableMap.of(); + public static final ImmutableMap DEFAULT_GLOBAL_PROPERTIES = ImmutableMap.of(); private String inputSpec; private String outputDir = DEFAULT_OUTPUT_DIR; @@ -62,7 +62,7 @@ public class WorkflowSettings { private String templateDir; private String templatingEngineName = DEFAULT_TEMPLATING_ENGINE_NAME; private String ignoreFileOverride; - private ImmutableMap systemProperties = DEFAULT_SYSTEM_PROPERTIES; + private ImmutableMap globalProperties = DEFAULT_GLOBAL_PROPERTIES; private WorkflowSettings(Builder builder) { this.inputSpec = builder.inputSpec; @@ -78,15 +78,7 @@ private WorkflowSettings(Builder builder) { this.templateDir = builder.templateDir; this.templatingEngineName = builder.templatingEngineName; this.ignoreFileOverride = builder.ignoreFileOverride; - // TODO: rename to globalProperties for 5.0 - this.systemProperties = ImmutableMap.copyOf(builder.systemProperties); - if (this.systemProperties.size() > 0) { - // write no more than every 5s. This is temporary until version 5.0 as once(Logger) is not accessible here. - // thread contention may cause this to write more than once, but this is just an attempt to reduce noise - if (System.currentTimeMillis() - lastWarning.getAndUpdate(x -> System.currentTimeMillis()) > 5000) { - LOGGER.warn("systemProperties will be renamed to globalProperties in version 5.0"); - } - } + this.globalProperties = ImmutableMap.copyOf(builder.globalProperties); } /** @@ -117,7 +109,7 @@ public static Builder newBuilder(WorkflowSettings copy) { builder.ignoreFileOverride = copy.getIgnoreFileOverride(); // this, and any other collections, must be mutable in the builder. - builder.systemProperties = new HashMap<>(copy.getSystemProperties()); + builder.globalProperties = new HashMap<>(copy.getGlobalProperties()); // force builder "with" methods to invoke side effects builder.withTemplateDir(copy.getTemplateDir()); @@ -264,8 +256,8 @@ public String getIgnoreFileOverride() { * * @return the system properties */ - public Map getSystemProperties() { - return systemProperties; + public Map getGlobalProperties() { + return globalProperties; } /** @@ -288,7 +280,7 @@ public static final class Builder { private String ignoreFileOverride; // NOTE: All collections must be mutable in the builder, and copied to a new immutable collection in .build() - private Map systemProperties = new HashMap<>();; + private Map globalProperties = new HashMap<>();; private Builder() { } @@ -469,30 +461,30 @@ public Builder withIgnoreFileOverride(String ignoreFileOverride) { } /** - * Sets the {@code systemProperties} and returns a reference to this Builder so that the methods can be chained together. + * Sets the {@code globalProperties} and returns a reference to this Builder so that the methods can be chained together. * - * @param systemProperties the {@code systemProperties} to set + * @param globalProperties the {@code globalProperties} to set * @return a reference to this Builder */ - public Builder withSystemProperties(Map systemProperties) { - if (systemProperties != null) { - this.systemProperties = systemProperties; + public Builder withGlobalProperties(Map globalProperties) { + if (globalProperties != null) { + this.globalProperties = globalProperties; } return this; } /** - * Sets the {@code systemProperties} and returns a reference to this Builder so that the methods can be chained together. + * Sets the {@code globalProperties} and returns a reference to this Builder so that the methods can be chained together. * * @param key The key of a system (global) property to set * @param value The value of a system (global) property to set * @return a reference to this Builder */ - public Builder withSystemProperty(String key, String value) { - if (this.systemProperties == null) { - this.systemProperties = new HashMap<>(); + public Builder withGlobalProperty(String key, String value) { + if (this.globalProperties == null) { + this.globalProperties = new HashMap<>(); } - this.systemProperties.put(key, value); + this.globalProperties.put(key, value); return this; } @@ -526,7 +518,7 @@ public String toString() { ", templateDir='" + templateDir + '\'' + ", templatingEngineName='" + templatingEngineName + '\'' + ", ignoreFileOverride='" + ignoreFileOverride + '\'' + - ", systemProperties=" + systemProperties + + ", globalProperties=" + globalProperties + '}'; } @@ -548,7 +540,7 @@ public boolean equals(Object o) { Objects.equals(getTemplateDir(), that.getTemplateDir()) && Objects.equals(getTemplatingEngineName(), that.getTemplatingEngineName()) && Objects.equals(getIgnoreFileOverride(), that.getIgnoreFileOverride()) && - Objects.equals(getSystemProperties(), that.getSystemProperties()); + Objects.equals(getGlobalProperties(), that.getGlobalProperties()); } @Override @@ -567,7 +559,7 @@ public int hashCode() { getTemplateDir(), getTemplatingEngineName(), getIgnoreFileOverride(), - getSystemProperties() + getGlobalProperties() ); } } diff --git a/modules/openapi-generator-core/src/test/java/org/openapitools/codegen/config/WorkflowSettingsTest.java b/modules/openapi-generator-core/src/test/java/org/openapitools/codegen/config/WorkflowSettingsTest.java index 3ab0048677c7..33638f767356 100644 --- a/modules/openapi-generator-core/src/test/java/org/openapitools/codegen/config/WorkflowSettingsTest.java +++ b/modules/openapi-generator-core/src/test/java/org/openapitools/codegen/config/WorkflowSettingsTest.java @@ -50,19 +50,19 @@ public void defaultValuesNotOverriddenByNulls(){ } @Test - public void newBuilderFromCopyShouldMutateSystemProperties(){ + public void newBuilderFromCopyShouldMutateGlobalProperties(){ WorkflowSettings original = WorkflowSettings.newBuilder() .withOutputDir("output") .withVerbose(true) .withSkipOverwrite(false) - .withSystemProperty("first", "1st") + .withGlobalProperty("first", "1st") .build(); WorkflowSettings modified = WorkflowSettings.newBuilder(original) - .withSystemProperty("second", "2nd") + .withGlobalProperty("second", "2nd") .build(); - Map properties = modified.getSystemProperties(); + Map properties = modified.getGlobalProperties(); assertEquals(properties.size(), 2, "System Properties map should allow mutation when invoked via copy constructor"); assertEquals(properties.getOrDefault("first", ""), "1st"); assertEquals(properties.getOrDefault("second", ""), "2nd"); diff --git a/modules/openapi-generator-gradle-plugin/README.adoc b/modules/openapi-generator-gradle-plugin/README.adoc index 7a8cef3596a5..2c10b0a8b342 100644 --- a/modules/openapi-generator-gradle-plugin/README.adoc +++ b/modules/openapi-generator-gradle-plugin/README.adoc @@ -135,10 +135,10 @@ apply plugin: 'org.openapi.generator' |None |Adds authorization headers when fetching the OpenAPI definitions remotely. Pass in a URL-encoded string of name:header with a comma separating multiple values. -|systemProperties +|globalProperties |Map(String,String) |None -|Sets specified system properties. +|Sets specified global properties. |configFile |String @@ -346,12 +346,12 @@ For more control over generation of individual files, configure an ignore file a [NOTE] ==== -When configuring `systemProperties` in order to perform selective generation you can disable generation of some parts by providing `"false"` value: +When configuring `globalProperties` in order to perform selective generation you can disable generation of some parts by providing `"false"` value: [source,groovy] ---- openApiGenerate { // other settings omitted - systemProperties = [ + globalProperties = [ modelDocs: "false", apis: "false" ] @@ -362,7 +362,7 @@ When enabling generation of only specific parts you either have to provide CSV l ---- openApiGenerate { // other settings omitted - systemProperties = [ + globalProperties = [ apis: "", models: "User,Pet" ] @@ -609,7 +609,7 @@ task buildKotlinClient(type: org.openapitools.generator.gradle.plugin.tasks.Gene configOptions = [ dateLibrary: "java8" ] - systemProperties = [ + globalProperties = [ modelDocs: "false" ] } diff --git a/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle b/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle index 22a21f46c6ff..cb99b8838faa 100644 --- a/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle +++ b/modules/openapi-generator-gradle-plugin/samples/local-spec/build.gradle @@ -42,7 +42,7 @@ openApiGenerate { configOptions = [ dateLibrary: "java8" ] - systemProperties = [ + globalProperties = [ modelDocs: "false" ] skipValidateSpec = true @@ -74,7 +74,7 @@ task buildDotnetSdk(type: org.openapitools.generator.gradle.plugin.tasks.Generat useCompareNetObjects: "true" ] outputDir = "$buildDir/csharp-netcore".toString() - systemProperties = [ + globalProperties = [ models: "", apis : "", ] diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt index dcc3ce08915d..84caadfad839 100644 --- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt +++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/OpenApiGeneratorPlugin.kt @@ -98,7 +98,7 @@ class OpenApiGeneratorPlugin : Plugin { inputSpec.set(generate.inputSpec) templateDir.set(generate.templateDir) auth.set(generate.auth) - systemProperties.set(generate.systemProperties) + globalProperties.set(generate.globalProperties) configFile.set(generate.configFile) skipOverwrite.set(generate.skipOverwrite) packageName.set(generate.packageName) diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt index daed01ae256e..4f099db7f6ff 100644 --- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt +++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/extensions/OpenApiGeneratorGenerateExtension.kt @@ -65,9 +65,9 @@ open class OpenApiGeneratorGenerateExtension(project: Project) { val auth = project.objects.property() /** - * Sets specified system properties. + * Sets specified global properties. */ - val systemProperties = project.objects.mapProperty() + val globalProperties = project.objects.mapProperty() /** * Path to json configuration file. diff --git a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt index 81a7e918c141..500597599b36 100644 --- a/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt +++ b/modules/openapi-generator-gradle-plugin/src/main/kotlin/org/openapitools/generator/gradle/plugin/tasks/GenerateTask.kt @@ -97,10 +97,10 @@ open class GenerateTask : DefaultTask() { val auth = project.objects.property() /** - * Sets specified system properties. + * Sets specified global properties. */ @get:Internal - val systemProperties = project.objects.mapProperty() + val globalProperties = project.objects.mapProperty() /** * Path to json configuration file. @@ -415,9 +415,9 @@ open class GenerateTask : DefaultTask() { } else CodegenConfigurator() try { - if (systemProperties.isPresent) { - systemProperties.get().forEach { (key, value) -> - configurator.addSystemProperty(key, value) + if (globalProperties.isPresent) { + globalProperties.get().forEach { (key, value) -> + configurator.addGlobalProperty(key, value) } } @@ -582,10 +582,9 @@ open class GenerateTask : DefaultTask() { } } - if (systemProperties.isPresent) { - // TODO: rename to globalProperties in 5.0 - systemProperties.get().forEach { entry -> - configurator.addSystemProperty(entry.key, entry.value) + if (globalProperties.isPresent) { + globalProperties.get().forEach { entry -> + configurator.addGlobalProperty(entry.key, entry.value) } } diff --git a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java index 90703b7f6031..628c15390c94 100644 --- a/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java +++ b/modules/openapi-generator-maven-plugin/src/main/java/org/openapitools/codegen/plugin/CodeGenMojo.java @@ -85,14 +85,6 @@ public class CodeGenMojo extends AbstractMojo { @Parameter(name = "verbose", defaultValue = "false") private boolean verbose; - // TODO: 5.0 Remove `language` option. - /** - * Client language to generate. - */ - @Parameter(name = "language") - private String language; - - /** * The name of the generator to use. */ @@ -538,20 +530,8 @@ public void execute() throws MojoExecutionException { configurator.setGenerateAliasAsModel(generateAliasAsModel); } - // TODO: After 3.0.0 release (maybe for 3.1.0): Fully deprecate lang. if (isNotEmpty(generatorName)) { configurator.setGeneratorName(generatorName); - - // check if generatorName & language are set together, inform user this needs to be updated to prevent future issues. - if (isNotEmpty(language)) { - LOGGER.warn("The 'language' option is deprecated and was replaced by 'generatorName'. Both can not be set together"); - throw new MojoExecutionException( - "Illegal configuration: 'language' and 'generatorName' can not be set both, remove 'language' from your configuration"); - } - } else if (isNotEmpty(language)) { - LOGGER.warn( - "The 'language' option is deprecated and may reference language names only in the next major release (4.0). Please use 'generatorName' instead."); - configurator.setGeneratorName(language); } else { LOGGER.error("A generator name (generatorName) is required."); throw new MojoExecutionException("The generator requires 'generatorName'. Refer to documentation for a list of options."); @@ -724,7 +704,7 @@ public void execute() throws MojoExecutionException { originalEnvironmentVariables.put(key, GlobalSettings.getProperty(key)); String value = environmentVariables.get(key); if (value != null) { - configurator.addSystemProperty(key, value); + configurator.addGlobalProperty(key, value); } } } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java index 840790ed4c8d..91458785e903 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfigurator.java @@ -61,7 +61,7 @@ public class CodegenConfigurator { private String generatorName; private String inputSpec; private String templatingEngineName; - private Map systemProperties = new HashMap<>(); + private Map globalProperties = new HashMap<>(); private Map instantiationTypes = new HashMap<>(); private Map typeMappings = new HashMap<>(); private Map additionalProperties = new HashMap<>(); @@ -91,8 +91,8 @@ public static CodegenConfigurator fromFile(String configFile, Module... modules) configurator.generatorName = generatorSettings.getGeneratorName(); configurator.inputSpec = workflowSettings.getInputSpec(); configurator.templatingEngineName = workflowSettings.getTemplatingEngineName(); - if (workflowSettings.getSystemProperties() != null) { - configurator.systemProperties.putAll(workflowSettings.getSystemProperties()); + if (workflowSettings.getGlobalProperties() != null) { + configurator.globalProperties.putAll(workflowSettings.getGlobalProperties()); } if(generatorSettings.getInstantiationTypes() != null) { configurator.instantiationTypes.putAll(generatorSettings.getInstantiationTypes()); @@ -183,10 +183,9 @@ public CodegenConfigurator addLanguageSpecificPrimitive(String value) { return this; } - // TODO: rename this and other references to "global property" rather than "system property" - public CodegenConfigurator addSystemProperty(String key, String value) { - this.systemProperties.put(key, value); - workflowSettingsBuilder.withSystemProperty(key, value); + public CodegenConfigurator addGlobalProperty(String key, String value) { + this.globalProperties.put(key, value); + workflowSettingsBuilder.withGlobalProperty(key, value); return this; } @@ -385,9 +384,9 @@ public CodegenConfigurator setStrictSpecBehavior(boolean strictSpecBehavior) { return this; } - public CodegenConfigurator setSystemProperties(Map systemProperties) { - this.systemProperties = systemProperties; - workflowSettingsBuilder.withSystemProperties(systemProperties); + public CodegenConfigurator setGlobalProperties(Map globalProperties) { + this.globalProperties = globalProperties; + workflowSettingsBuilder.withGlobalProperties(globalProperties); return this; } @@ -450,7 +449,7 @@ public Context toContext() { GlobalSettings.setProperty("verbose", "false"); } - for (Map.Entry entry : workflowSettings.getSystemProperties().entrySet()) { + for (Map.Entry entry : workflowSettings.getGlobalProperties().entrySet()) { GlobalSettings.setProperty(entry.getKey(), entry.getValue()); } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfiguratorUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfiguratorUtils.java index b3154db6407a..e6251baa8f04 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfiguratorUtils.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/config/CodegenConfiguratorUtils.java @@ -42,39 +42,6 @@ */ public final class CodegenConfiguratorUtils { - /** - * Applies "system" properties to the configurator as global properties. - * - * @deprecated - * This method is deprecated due to confusion around the tool's use of system properties. We called these system properties - * in the past and accepted them via CLI option -D. This lead to confusion between true Java System Properties and generator-specific - * "system level properties". They've since been renamed as "Global Properties". Please use {@link CodegenConfiguratorUtils#applyGlobalPropertiesKvpList(List, CodegenConfigurator)}. - * - * @param systemProperties List of properties to be globally available throughout the generator execution. - * @param configurator The {@link CodegenConfigurator} instance to configure. - */ - @Deprecated - public static void applySystemPropertiesKvpList(List systemProperties, CodegenConfigurator configurator) { - // TODO: Remove in 5.0 - applyGlobalPropertiesKvpList(systemProperties, configurator); - } - - /** - * Applies a key-value pair of strings as "system" properties to the configurator as global properties. - * - * @deprecated - * This method is deprecated due to confusing between Java Sytsem Properties and generator-specific "system-level properties". - * They've since been renamed as "Global Properties". Please use {@link CodegenConfiguratorUtils#applyGlobalPropertiesKvp(String, CodegenConfigurator)}. - * - * @param systemProperties List of properties to be globally available throughout the generator execution. - * @param configurator The {@link CodegenConfigurator} instance to configure. - */ - @Deprecated - public static void applySystemPropertiesKvp(String systemProperties, CodegenConfigurator configurator) { - // TODO: Remove in 5.0 - applyGlobalPropertiesKvp(systemProperties, configurator); - } - public static void applyGlobalPropertiesKvpList(List globalProperties, CodegenConfigurator configurator) { for(String propString : globalProperties) { applyGlobalPropertiesKvp(propString, configurator); @@ -84,7 +51,7 @@ public static void applyGlobalPropertiesKvpList(List globalProperties, C public static void applyGlobalPropertiesKvp(String globalProperties, CodegenConfigurator configurator) { final Map map = createMapFromKeyValuePairs(globalProperties); for (Map.Entry entry : map.entrySet()) { - configurator.addSystemProperty(entry.getKey(), entry.getValue()); + configurator.addGlobalProperty(entry.getKey(), entry.getValue()); } } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/AbstractIntegrationTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/AbstractIntegrationTest.java index fce15f7b2e73..81c4978e7873 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/AbstractIntegrationTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/AbstractIntegrationTest.java @@ -38,14 +38,14 @@ public abstract class AbstractIntegrationTest { protected Boolean generateMetadata = true; - protected Map systemPropertyOverrides = new HashMap<>(); + protected Map globalPropertyOverrides = new HashMap<>(); // @wing328: ignore for the time being until we fix the error with the integration test @Test(enabled = false) public void generatesCorrectDirectoryStructure() throws IOException { DefaultGenerator codeGen = new DefaultGenerator(); codeGen.setGenerateMetadata(generateMetadata); - for (Map.Entry propertyOverride : systemPropertyOverrides.entrySet()) { + for (Map.Entry propertyOverride : globalPropertyOverrides.entrySet()) { codeGen.setGeneratorPropertyDefault(propertyOverride.getKey(), propertyOverride.getValue()); } diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/config/CodegenConfiguratorTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/config/CodegenConfiguratorTest.java index 7cd8aa957989..7055bff46595 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/config/CodegenConfiguratorTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/config/CodegenConfiguratorTest.java @@ -19,7 +19,6 @@ import org.openapitools.codegen.ClientOptInput; import org.openapitools.codegen.CodegenConfig; import org.openapitools.codegen.CodegenConstants; -import org.openapitools.codegen.DefaultGenerator; import org.testng.annotations.Test; import java.io.File; @@ -66,7 +65,7 @@ public void shouldSetConfiglProperties() throws IOException { .addImportMapping("one", "two") .addInstantiationType("three", "four") .addLanguageSpecificPrimitive("five") - .addSystemProperty("six", "seven") + .addGlobalProperty("six", "seven") .addTypeMapping("eight", "nine") .setApiPackage("test-api") .setArtifactId("test-artifactId") diff --git a/modules/openapi-generator/src/test/resources/sampleConfig.json b/modules/openapi-generator/src/test/resources/sampleConfig.json index 17dd8ab86696..1c59ab4e5461 100644 --- a/modules/openapi-generator/src/test/resources/sampleConfig.json +++ b/modules/openapi-generator/src/test/resources/sampleConfig.json @@ -14,7 +14,7 @@ "artifactVersion" : "1.2.3", "library" : "jersey2", "ignoreFileOverride": "/path/to/override/.openapi-generator-ignore", - "systemProperties" : { + "globalProperties" : { "systemProp1" : "value1" }, "instantiationTypes" : { From b4572c4bbfa977bdcfae7c85df86058a83810664 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sun, 26 Apr 2020 10:44:11 -0400 Subject: [PATCH 03/16] [docs] Update site with global properties list and usage explanation --- docs/customization.md | 3 ++- docs/global-properties.md | 43 ++++++++++++++++++++++++++++++++++++ docs/usage.md | 25 +++++++++++---------- website/docusaurus.config.js | 2 +- website/sidebars.js | 3 ++- 5 files changed, 61 insertions(+), 15 deletions(-) create mode 100644 docs/global-properties.md diff --git a/docs/customization.md b/docs/customization.md index fbdc5a890cdb..04058ad92bbf 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -90,7 +90,8 @@ You can use this as additional dependency of the `openapi-generator-maven-plugin If you publish your artifact to a distant maven repository, do not forget to add this repository as `pluginRepository` for your project. ## Selective generation -You may not want to generate *all* models in your project. Likewise you may want just one or two apis to be written. If that's the case, you can use system properties to control the output: + +You may not want to generate *all* models in your project. Likewise, you may want just one or two apis to be written. If that's the case, you can use system properties or [global properties](./global-properties.md) to control the output. The default is generate *everything* supported by the specific library. Once you enable a feature, it will restrict the contents generated: diff --git a/docs/global-properties.md b/docs/global-properties.md new file mode 100644 index 000000000000..c2c0aab64788 --- /dev/null +++ b/docs/global-properties.md @@ -0,0 +1,43 @@ +--- +id: globals +title: Global Properties +--- + +## Available Global Properties + +| Property | Description | Acceptable value | +| -------- | ------------| ---------------- | +| debugOpenAPI | Dumps JSON formatted and fully parsed OpenAPI document during generation | none | +| debugModels | Dumps JSON formatted template-bound model information during generation | none | +| debugOperations | Dumps JSON formatted template-bound operation information during generation | none | +| debugSupportingFiles | Dumps JSON formatted Supporting File information during generation | none | +| verbose | Defines the verbosity | `true` or `false` | +| generateAliasAsModel | Defines whether primitive types defined at the model/schema level will be wrapped in a model | `true` or `false` | +| org.openapitools.codegen.utils.oncelogger.enabled | Enable/disable the "OnceLogger" which reduces noise for select repeated logs | `true` or `false` | +| supportingFiles | Allows the user to define which supporting files will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a comma-separated string of file names | +| models | Allows the user to define which models will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a comma-separated string of model names | +| apis | Allows the user to define which apis will be generated. Prefer using the more robust `.openapi-generator-ignore`. | no value, or a comma-separated string of api names | +| apiDocs | Allows the user to define if api docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` | +| modelDocs | Allows the user to define if model docs will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` | +| apiTests | Allows the user to define if api tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` | +| modelTests | Allows the user to define if model tests will be generated. Prefer using the more robust `.openapi-generator-ignore`. | `true` or `false` | +| withXml | Allows the user to control support of XML generated constructs, where supported | none | + + +## Note on Global Property declaration + +There are _two ways_ to provide selective generation properties or "global properties". First, these can be passed as Java System Properties. Second, these can be passed via the global property tooling option (`--global-property` in CLI and `globalProperty` in Maven and Gradle configurations). This differentiation is new in version 5.0 with the removal of the `-D` CLI option and the renaming of `systemProperties`. If you're upgrading to OpenAPI Generator 5.0+ + +While the examples seen in [Customization](./customization.md) use the Java System Property syntax, keep in mind that the following are equivalent: + +```sh +java -Dmodels {jar} generate {opts} +``` + +and + +```sh +java {jar} generate {opts} --global-property=models +``` + +Why the two differing ways to provide the same properties? We previously accepted a `-D` tooling option which resembled Java System Property declaration. In older versions of OpenAPI Generator, the option modified the SystemProperties collection directly and was truly a "system property". This option changed during the 4.x release in an effort to make OpenAPI Generator thread-safe and isolate its configuration via thread locals. We no longer mutate System Properties. In the 4.x release and earlier, specifying the tooling `-D` option with system properties intended for other tools like swagger-parser rather than passing them as true Java System Properties would lead to unexpected behavior for the user; if our tool set the system property _after_ invoking certain code, it would seem to the user like Java System Properties weren't working! \ No newline at end of file diff --git a/docs/usage.md b/docs/usage.md index cddfd145ca9e..8e5e0263d868 100644 --- a/docs/usage.md +++ b/docs/usage.md @@ -260,14 +260,14 @@ SYNOPSIS [(-a | --auth )] [--api-name-suffix ] [--api-package ] [--artifact-id ] [--artifact-version ] - [(-c | --config )] - [-D ...] [--dry-run] + [(-c | --config )] [--dry-run] [(-e | --engine )] [--enable-post-process-file] [(-g | --generator-name )] [--generate-alias-as-model] [--git-host ] [--git-repo-id ] [--git-user-id ] - [--group-id ] [--http-user-agent ] + [--global-property ...] [--group-id ] + [--http-user-agent ] (-i | --input-spec ) [--ignore-file-override ] [--import-mappings ...] @@ -323,10 +323,6 @@ OPTIONS different for each language. Run config-help -g {generator name} command for language-specific config options. - -D - sets specified system properties in the format of - name=value,name=value (or multiple options, each with name=value) - --dry-run Try things out and report on potential changes (without actually making changes). @@ -342,11 +338,11 @@ OPTIONS --generate-alias-as-model Generate model implementation for aliases to map and array schemas. - An 'alias' is an array, map, or list which is defined inline in a - OpenAPI document and becomes a model in the generated code. - A 'map' schema is an object that can have undeclared properties, - i.e. the 'additionalproperties' attribute is set on that object. - An 'array' schema is a list of sub schemas in a OAS document. + An 'alias' is an array, map, or list which is defined inline in a + OpenAPI document and becomes a model in the generated code. A 'map' + schema is an object that can have undeclared properties, i.e. the + 'additionalproperties' attribute is set on that object. An 'array' + schema is a list of sub schemas in a OAS document --git-host Git host, e.g. gitlab.com. @@ -357,6 +353,11 @@ OPTIONS --git-user-id Git user ID, e.g. openapitools. + --global-property + sets specified global properties (previously called 'system + properties') in the format of name=value,name=value (or multiple + options, each with name=value) + --group-id groupId in generated pom.xml diff --git a/website/docusaurus.config.js b/website/docusaurus.config.js index c37c1641f024..defb23afd922 100755 --- a/website/docusaurus.config.js +++ b/website/docusaurus.config.js @@ -46,7 +46,7 @@ const docusaurusConfig = { }, links: [ - {to: 'docs/installation', label: 'Install'}, + {to: 'docs/installation', label: 'Getting Started'}, {to: 'docs/generators', label: 'Generators'}, {to: 'docs/roadmap', label: 'Roadmap'}, {to: "docs/faq", label: "FAQ" }, diff --git a/website/sidebars.js b/website/sidebars.js index 3c715231a70f..0880123d523c 100755 --- a/website/sidebars.js +++ b/website/sidebars.js @@ -5,7 +5,8 @@ module.exports = { 'installation', 'plugins', 'online', - 'usage' + 'usage', + 'globals' ], 'Extending': [ 'templating', From dc7eef786c68533892b9558b4ef6d65e03c1bafc Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sun, 10 May 2020 15:11:03 -0400 Subject: [PATCH 04/16] Use proper vendor extension casing in all templates --- .../main/resources/apex/model_test.mustache | 16 +-- .../src/main/resources/apex/pojo.mustache | 12 +- .../main/resources/dart-jaguar/api.mustache | 4 +- .../main/resources/dart-jaguar/class.mustache | 4 +- .../haskell-http-client/MimeTypes.mustache | 4 +- .../haskell-http-client/Model.mustache | 34 +++--- .../tests/Instances.mustache | 2 +- .../mysql-schema/mysql_schema.mustache | 14 +-- .../resources/mysql-schema/sql_query.mustache | 16 +-- .../src/main/resources/ocaml/of_json.mustache | 2 +- .../src/main/resources/ocaml/to_json.mustache | 2 +- .../main/resources/ocaml/to_string.mustache | 2 +- .../resources/rust-server/README.mustache | 4 +- .../rust-server/client-callbacks.mustache | 2 +- .../rust-server/client-operation.mustache | 72 ++++++------ .../rust-server/example-client-main.mustache | 16 +-- .../example-server-operation.mustache | 8 +- .../main/resources/rust-server/lib.mustache | 32 ++--- .../resources/rust-server/models.mustache | 22 ++-- .../resources/rust-server/response.mustache | 22 ++-- .../rust-server/server-operation.mustache | 110 +++++++++--------- .../src/main/resources/rust/model.mustache | 4 +- 22 files changed, 202 insertions(+), 202 deletions(-) diff --git a/modules/openapi-generator/src/main/resources/apex/model_test.mustache b/modules/openapi-generator/src/main/resources/apex/model_test.mustache index 3aef0d655725..b3a49b28b505 100644 --- a/modules/openapi-generator/src/main/resources/apex/model_test.mustache +++ b/modules/openapi-generator/src/main/resources/apex/model_test.mustache @@ -86,18 +86,18 @@ private class {{classname}}Test { System.assertEquals({{classVarName}}3.hashCode(), {{classVarName}}4.hashCode()); } {{#vendorExtensions}} - {{#hasPropertyMappings}} + {{#x-has-property-mappings}} @isTest private static void maintainRenamedProperties() { {{classname}} {{classVarName}} = new {{classname}}(); - Map propertyMappings = {{classVarName}}.getPropertyMappings(); - {{#propertyMappings}} - System.assertEquals('{{internalName}}', propertyMappings.get('{{externalName}}')); - {{/propertyMappings}} + Map x-property-mappings = {{classVarName}}.getx-property-mappings(); + {{#x-property-mappings}} + System.assertEquals('{{internalName}}', x-property-mappings.get('{{externalName}}')); + {{/x-property-mappings}} } - {{/hasPropertyMappings}} - {{#hasDefaultValues}} + {{/x-has-property-mappings}} + {{#x-has-default-values}} @isTest private static void defaultValuesPopulated() { @@ -113,7 +113,7 @@ private class {{classname}}Test { {{/defaultValue}} {{/vars}} } - {{/hasDefaultValues}} + {{/x-has-default-values}} {{/vendorExtensions}} {{/isEnum}} } diff --git a/modules/openapi-generator/src/main/resources/apex/pojo.mustache b/modules/openapi-generator/src/main/resources/apex/pojo.mustache index 9f192178eeac..74f64634440b 100644 --- a/modules/openapi-generator/src/main/resources/apex/pojo.mustache +++ b/modules/openapi-generator/src/main/resources/apex/pojo.mustache @@ -34,19 +34,19 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{#interfac {{/vars}} {{#vendorExtensions}} - {{#hasPropertyMappings}} + {{#x-property-mappings}} private static final Map propertyMappings = new Map{ - {{#propertyMappings}} + {{#x-property-mappings}} '{{externalName}}' => '{{internalName}}'{{^-last}},{{/-last}} - {{/propertyMappings}} + {{/x-property-mappings}} }; public Map getPropertyMappings() { return propertyMappings; } - {{/hasPropertyMappings}} - {{#hasDefaultValues}} + {{/x-property-mappings}} + {{#x-has-default-values}} public {{classname}}() { {{#vars}} {{#defaultValue}} @@ -55,7 +55,7 @@ public class {{classname}}{{#parent}} extends {{{parent}}}{{/parent}}{{#interfac {{/vars}} } - {{/hasDefaultValues}} + {{/x-has-default-values}} {{/vendorExtensions}} public static {{classname}} getExample() { {{classname}} {{classVarName}} = new {{classname}}(); diff --git a/modules/openapi-generator/src/main/resources/dart-jaguar/api.mustache b/modules/openapi-generator/src/main/resources/dart-jaguar/api.mustache index 4d1a4c5931cd..339e22af3c9d 100644 --- a/modules/openapi-generator/src/main/resources/dart-jaguar/api.mustache +++ b/modules/openapi-generator/src/main/resources/dart-jaguar/api.mustache @@ -40,11 +40,11 @@ class {{classname}} extends ApiClient with _${{classname}}Client { {{#vendorExtensions}} {{#formParams}} {{#-first}}{{#hasQueryParams}},{{/hasQueryParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/-first}} - {{#isJson}}@AsJson() {{/isJson}}{{#isForm}}@AsFormField() {{/isForm}}{{#isMultipart}}@AsMultipartField() {{/isMultipart}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}} + {{#x-is-json}}@AsJson() {{/x-is-json}}{{#x-is-form}}@AsFormField() {{/x-is-form}}{{#x-is-multipart}}@AsMultipartField() {{/x-is-multipart}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}} {{/formParams}} {{#bodyParam}} {{#hasFormParams}},{{/hasFormParams}}{{^hasFormParams}}{{#hasQueryParams}},{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{#hasHeaderParams}},{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}}{{^hasFormParams}}{{^hasQueryParams}}{{^hasHeaderParams}}{{#hasPathParams}},{{/hasPathParams}}{{/hasHeaderParams}}{{/hasQueryParams}}{{/hasFormParams}} - {{^isProto}}{{^isJson}}{{^isForm}}{{^isMultipart}}@AsBody(){{/isMultipart}}{{/isForm}}{{/isJson}}{{/isProto}} {{#isProto}}@Serialized(MimeTypes.binary) {{/isProto}}{{#isJson}}@AsJson() {{/isJson}}{{#isForm}}@AsForm() {{/isForm}}{{#isMultipart}}@AsMultipart() {{/isMultipart}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}} + {{^x-is-proto}}{{^x-is-json}}{{^x-is-form}}{{^x-is-multipart}}@AsBody(){{/x-is-multipart}}{{/x-is-form}}{{/x-is-json}}{{/x-is-proto}} {{#x-is-proto}}@Serialized(MimeTypes.binary) {{/x-is-proto}}{{#x-is-json}}@AsJson() {{/x-is-json}}{{#x-is-form}}@AsForm() {{/x-is-form}}{{#x-is-multipart}}@AsMultipart() {{/x-is-multipart}}{{{dataType}}} {{paramName}}{{#hasMore}}, {{/hasMore}} {{/bodyParam}} {{/vendorExtensions}} ) { diff --git a/modules/openapi-generator/src/main/resources/dart-jaguar/class.mustache b/modules/openapi-generator/src/main/resources/dart-jaguar/class.mustache index 0ee26193bba5..5a5edb919999 100644 --- a/modules/openapi-generator/src/main/resources/dart-jaguar/class.mustache +++ b/modules/openapi-generator/src/main/resources/dart-jaguar/class.mustache @@ -22,10 +22,10 @@ class {{classname}} { {{classname}}( {{#vars}}{{^defaultValue}}{{#required}} this.{{name}}, {{/required}}{{/defaultValue}}{{/vars}} -{{#vendorExtensions}}{{#hasVars}}{ +{{#vendorExtensions}}{{#x-has-vars}}{ {{#vars}}{{^required}} this.{{name}}{{#defaultValue}} = {{{defaultValue}}}{{#hasMore}}, {{/hasMore}} {{/defaultValue}}{{/required}} {{#required}} {{#defaultValue}}this.{{name}} = {{{defaultValue}}}{{#hasMore}}, {{/hasMore}} {{/defaultValue}}{{/required}}{{/vars}} - }{{/hasVars}}{{/vendorExtensions}} + }{{/x-has-vars}}{{/vendorExtensions}} ); @override diff --git a/modules/openapi-generator/src/main/resources/haskell-http-client/MimeTypes.mustache b/modules/openapi-generator/src/main/resources/haskell-http-client/MimeTypes.mustache index c1c83ec7120d..b9bdd3e27335 100644 --- a/modules/openapi-generator/src/main/resources/haskell-http-client/MimeTypes.mustache +++ b/modules/openapi-generator/src/main/resources/haskell-http-client/MimeTypes.mustache @@ -195,7 +195,7 @@ instance MimeUnrender MimeNoContent NoContent where mimeUnrender _ = P.Right . P {{#x-hasUnknownMimeTypes}} -- * Custom Mime Types -{{#x-unknownMimeTypes}}-- ** {{{x-mediaDataType}}} +{{#x-unknown-mime-types}}-- ** {{{x-mediaDataType}}} data {{{x-mediaDataType}}} = {{{x-mediaDataType}}} deriving (P.Typeable) @@ -207,4 +207,4 @@ instance A.FromJSON a => MimeUnrender {{{x-mediaDataType}}} a where mimeUnrender -- instance MimeRender {{{x-mediaDataType}}} T.Text where mimeRender _ = undefined -- instance MimeUnrender {{{x-mediaDataType}}} T.Text where mimeUnrender _ = undefined -{{/x-unknownMimeTypes}}{{/x-hasUnknownMimeTypes}} \ No newline at end of file +{{/x-unknown-mime-types}}{{/x-hasUnknownMimeTypes}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/haskell-http-client/Model.mustache b/modules/openapi-generator/src/main/resources/haskell-http-client/Model.mustache index d8dd9f0f2489..c42a4ee01ff9 100644 --- a/modules/openapi-generator/src/main/resources/haskell-http-client/Model.mustache +++ b/modules/openapi-generator/src/main/resources/haskell-http-client/Model.mustache @@ -58,8 +58,8 @@ import qualified Prelude as P -- * Parameter newtypes {{#x-allUniqueParams}}{{#x-newtype}} --- ** {{{x-paramNameType}}} -newtype {{{x-paramNameType}}} = {{{x-paramNameType}}} { un{{{x-paramNameType}}} :: {{{x-dataType}}} } deriving (P.Eq, P.Show{{#x-isBodyParam}}, A.ToJSON{{/x-isBodyParam}}){{/x-newtype}}{{/x-allUniqueParams}} +-- ** {{{x-param-name-type}}} +newtype {{{x-param-name-type}}} = {{{x-param-name-type}}} { un{{{x-param-name-type}}} :: {{{x-data-type}}} } deriving (P.Eq, P.Show{{#x-isBodyParam}}, A.ToJSON{{/x-isBodyParam}}){{/x-newtype}}{{/x-allUniqueParams}} -- * Models @@ -125,30 +125,30 @@ mk{{classname}} {{#vars}}{{#required}}{{name}} {{/required}}{{/vars}}= {{#x-hasEnumSection}}-- * Enums {{#x-allUniqueParams}}{{#x-enum}} --- ** {{{x-paramNameType}}} +-- ** {{{x-param-name-type}}} --- | Enum of '{{{x-dataType}}}'{{#description}} . +-- | Enum of '{{{x-data-type}}}'{{#description}} . -- {{{.}}}{{/description}} -data {{{x-paramNameType}}} +data {{{x-param-name-type}}} = {{#allowableValues}}{{#enumVars}}{{{name}}} -- ^ @{{{value}}}@ {{^-last}}| {{/-last}}{{#-last}}deriving (P.Show, P.Eq, P.Typeable, P.Ord, P.Bounded, P.Enum){{/-last}}{{/enumVars}}{{/allowableValues}} -instance A.ToJSON {{{x-paramNameType}}} where toJSON = A.toJSON . from{{{x-paramNameType}}} -instance A.FromJSON {{{x-paramNameType}}} where parseJSON o = P.either P.fail (pure . P.id) . to{{{x-paramNameType}}} =<< A.parseJSON o -instance WH.ToHttpApiData {{{x-paramNameType}}} where toQueryParam = WH.toQueryParam . from{{{x-paramNameType}}} -instance WH.FromHttpApiData {{{x-paramNameType}}} where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . to{{{x-paramNameType}}} -instance MimeRender MimeMultipartFormData {{{x-paramNameType}}} where mimeRender _ = mimeRenderDefaultMultipartFormData +instance A.ToJSON {{{x-param-name-type}}} where toJSON = A.toJSON . from{{{x-param-name-type}}} +instance A.FromJSON {{{x-param-name-type}}} where parseJSON o = P.either P.fail (pure . P.id) . to{{{x-param-name-type}}} =<< A.parseJSON o +instance WH.ToHttpApiData {{{x-param-name-type}}} where toQueryParam = WH.toQueryParam . from{{{x-param-name-type}}} +instance WH.FromHttpApiData {{{x-param-name-type}}} where parseQueryParam o = WH.parseQueryParam o >>= P.left T.pack . to{{{x-param-name-type}}} +instance MimeRender MimeMultipartFormData {{{x-param-name-type}}} where mimeRender _ = mimeRenderDefaultMultipartFormData --- | unwrap '{{{x-paramNameType}}}' enum -from{{{x-paramNameType}}} :: {{{x-paramNameType}}} -> {{{x-dataType}}} -from{{{x-paramNameType}}} = \case{{#allowableValues}}{{#enumVars}} +-- | unwrap '{{{x-param-name-type}}}' enum +from{{{x-param-name-type}}} :: {{{x-param-name-type}}} -> {{{x-data-type}}} +from{{{x-param-name-type}}} = \case{{#allowableValues}}{{#enumVars}} {{{name}}} -> {{{value}}}{{/enumVars}}{{/allowableValues}} --- | parse '{{{x-paramNameType}}}' enum -to{{{x-paramNameType}}} :: {{{x-dataType}}} -> P.Either String {{{x-paramNameType}}} -to{{{x-paramNameType}}} = \case{{#allowableValues}}{{#enumVars}} +-- | parse '{{{x-param-name-type}}}' enum +to{{{x-param-name-type}}} :: {{{x-data-type}}} -> P.Either String {{{x-param-name-type}}} +to{{{x-param-name-type}}} = \case{{#allowableValues}}{{#enumVars}} {{{value}}} -> P.Right {{{name}}}{{/enumVars}}{{/allowableValues}} - s -> P.Left $ "to{{{x-paramNameType}}}: enum parse failure: " P.++ P.show s + s -> P.Left $ "to{{{x-param-name-type}}}: enum parse failure: " P.++ P.show s {{/x-enum}}{{/x-allUniqueParams}}{{/x-hasEnumSection}} {{#authMethods}}{{#-first}}-- * Auth Methods diff --git a/modules/openapi-generator/src/main/resources/haskell-http-client/tests/Instances.mustache b/modules/openapi-generator/src/main/resources/haskell-http-client/tests/Instances.mustache index a684c08db710..a3232a07daa8 100644 --- a/modules/openapi-generator/src/main/resources/haskell-http-client/tests/Instances.mustache +++ b/modules/openapi-generator/src/main/resources/haskell-http-client/tests/Instances.mustache @@ -123,6 +123,6 @@ gen{{classname}} n = {{#x-allUniqueParams}}{{#x-enum}} -instance Arbitrary {{{x-paramNameType}}} where +instance Arbitrary {{{x-param-name-type}}} where arbitrary = arbitraryBoundedEnum {{/x-enum}}{{/x-allUniqueParams}} diff --git a/modules/openapi-generator/src/main/resources/mysql-schema/mysql_schema.mustache b/modules/openapi-generator/src/main/resources/mysql-schema/mysql_schema.mustache index 9ccdef756432..e54dc6daf336 100644 --- a/modules/openapi-generator/src/main/resources/mysql-schema/mysql_schema.mustache +++ b/modules/openapi-generator/src/main/resources/mysql-schema/mysql_schema.mustache @@ -12,34 +12,34 @@ CREATE DATABASE IF NOT EXISTS `{{{defaultDatabaseName}}}` DEFAULT CHARACTER SET -- -------------------------------------------------------- {{#models}}{{#model}}{{#hasVars}}{{^isArrayModel}}-- --- Table structure{{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}} for table `{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} generated from model '{{classVarName}}' +-- Table structure{{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}} for table `{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} generated from model '{{classVarName}}' {{#description}} -- {{description}} {{/description}} -- {{#vendorExtensions}} -{{#x-mysqlSchema}} +{{#x-mysql-schema}} {{#tableDefinition}} CREATE TABLE IF NOT EXISTS {{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}` ( {{/tableDefinition}} -{{/x-mysqlSchema}} +{{/x-mysql-schema}} {{/vendorExtensions}} {{#vars}} {{#vendorExtensions}} - {{#x-mysqlSchema}} + {{#x-mysql-schema}} {{#columnDefinition}} `{{colName}}` {{colDataType}}{{#colDataTypeArguments}}{{#-first}}({{/-first}}{{#isString}}'{{/isString}}{{argumentValue}}{{#isString}}'{{/isString}}{{^-last}}, {{/-last}}{{#-last}}){{/-last}}{{/colDataTypeArguments}}{{#colUnsigned}} UNSIGNED{{/colUnsigned}}{{#colNotNull}} NOT NULL{{/colNotNull}}{{#colDefault}} DEFAULT {{#isString}}'{{defaultValue}}'{{/isString}}{{^isString}}{{defaultValue}}{{/isString}}{{/colDefault}}{{#colComment}} COMMENT '{{colComment}}'{{/colComment}}{{^-last}},{{/-last}} {{/columnDefinition}} - {{/x-mysqlSchema}} + {{/x-mysql-schema}} {{/vendorExtensions}} {{/vars}} {{#vendorExtensions}} -{{#x-mysqlSchema}} +{{#x-mysql-schema}} {{#tableDefinition}} ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci{{#tblComment}} COMMENT='{{tblComment}}'{{/tblComment}}; {{/tableDefinition}} -{{/x-mysqlSchema}} +{{/x-mysql-schema}} {{/vendorExtensions}} {{/isArrayModel}}{{/hasVars}}{{/model}}{{/models}} diff --git a/modules/openapi-generator/src/main/resources/mysql-schema/sql_query.mustache b/modules/openapi-generator/src/main/resources/mysql-schema/sql_query.mustache index 888ecb3e8a7d..7775e7c70d30 100644 --- a/modules/openapi-generator/src/main/resources/mysql-schema/sql_query.mustache +++ b/modules/openapi-generator/src/main/resources/mysql-schema/sql_query.mustache @@ -6,22 +6,22 @@ {{#models}}{{#model}} -- --- SELECT template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} +-- SELECT template for table {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} -- -SELECT {{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}`{{colName}}`{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}} FROM {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} WHERE 1; +SELECT {{#vars}}{{#vendorExtensions}}{{#x-mysql-schema}}{{#columnDefinition}}`{{colName}}`{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}{{/vars}} FROM {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} WHERE 1; -- --- INSERT template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} +-- INSERT template for table {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} -- -INSERT INTO {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}({{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}`{{colName}}`{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}}) VALUES ({{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}{{#namedParametersEnabled}}:{{colName}}{{/namedParametersEnabled}}{{^namedParametersEnabled}}?{{/namedParametersEnabled}}{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}}); +INSERT INTO {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}({{#vars}}{{#vendorExtensions}}{{#x-mysql-schema}}{{#columnDefinition}}`{{colName}}`{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}{{/vars}}) VALUES ({{#vars}}{{#vendorExtensions}}{{#x-mysql-schema}}{{#columnDefinition}}{{#namedParametersEnabled}}:{{colName}}{{/namedParametersEnabled}}{{^namedParametersEnabled}}?{{/namedParametersEnabled}}{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}{{/vars}}); -- --- UPDATE template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} +-- UPDATE template for table {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} -- -UPDATE {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} SET {{#vars}}{{#vendorExtensions}}{{#x-mysqlSchema}}{{#columnDefinition}}`{{colName}}` = {{#namedParametersEnabled}}:{{colName}}{{/namedParametersEnabled}}{{^namedParametersEnabled}}?{{/namedParametersEnabled}}{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}}{{/vars}} WHERE 1; +UPDATE {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} SET {{#vars}}{{#vendorExtensions}}{{#x-mysql-schema}}{{#columnDefinition}}`{{colName}}` = {{#namedParametersEnabled}}:{{colName}}{{/namedParametersEnabled}}{{^namedParametersEnabled}}?{{/namedParametersEnabled}}{{#hasMore}}, {{/hasMore}}{{/columnDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}}{{/vars}} WHERE 1; -- --- DELETE template for table {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} +-- DELETE template for table {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} -- -DELETE FROM {{#vendorExtensions}}{{#x-mysqlSchema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysqlSchema}}{{/vendorExtensions}} WHERE 0; +DELETE FROM {{#vendorExtensions}}{{#x-mysql-schema}}{{#tableDefinition}}{{#defaultDatabaseName}}`{{{defaultDatabaseName}}}`.{{/defaultDatabaseName}}`{{tblName}}`{{/tableDefinition}}{{/x-mysql-schema}}{{/vendorExtensions}} WHERE 0; {{/model}}{{/models}} diff --git a/modules/openapi-generator/src/main/resources/ocaml/of_json.mustache b/modules/openapi-generator/src/main/resources/ocaml/of_json.mustache index a7be3d4d7ca5..be01eeafa4c4 100644 --- a/modules/openapi-generator/src/main/resources/ocaml/of_json.mustache +++ b/modules/openapi-generator/src/main/resources/ocaml/of_json.mustache @@ -1 +1 @@ -{{#isEnum}}JsonSupport.unwrap Enums.{{{datatypeWithEnum}}}_of_yojson{{/isEnum}}{{^isEnum}}{{#returnType}}{{#returnTypeIsPrimitive}}JsonSupport.to_{{{returnBaseType}}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{#vendorExtensions.x-modelModule}}JsonSupport.unwrap {{{vendorExtensions.x-modelModule}}}.of_yojson{{/vendorExtensions.x-modelModule}}{{^vendorExtensions.x-modelModule}}JsonSupport.unwrap {{{returnBaseType}}}.of_yojson{{/vendorExtensions.x-modelModule}}{{/returnTypeIsPrimitive}}{{/returnType}}{{/isEnum}} \ No newline at end of file +{{#isEnum}}JsonSupport.unwrap Enums.{{{datatypeWithEnum}}}_of_yojson{{/isEnum}}{{^isEnum}}{{#returnType}}{{#returnTypeIsPrimitive}}JsonSupport.to_{{{returnBaseType}}}{{/returnTypeIsPrimitive}}{{^returnTypeIsPrimitive}}{{#vendorExtensions.x-model-module}}JsonSupport.unwrap {{{vendorExtensions.x-model-module}}}.of_yojson{{/vendorExtensions.x-model-module}}{{^vendorExtensions.x-model-module}}JsonSupport.unwrap {{{returnBaseType}}}.of_yojson{{/vendorExtensions.x-model-module}}{{/returnTypeIsPrimitive}}{{/returnType}}{{/isEnum}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/ocaml/to_json.mustache b/modules/openapi-generator/src/main/resources/ocaml/to_json.mustache index 6b8fea90fdcd..a0fa3504a7aa 100644 --- a/modules/openapi-generator/src/main/resources/ocaml/to_json.mustache +++ b/modules/openapi-generator/src/main/resources/ocaml/to_json.mustache @@ -1 +1 @@ -{{#isListContainer}}{{#items}}(JsonSupport.of_list_of {{> to_json}}){{/items}}{{/isListContainer}}{{#isMapContainer}}{{#items}}(JsonSupport.of_map_of {{> to_json}}){{/items}}{{/isMapContainer}}{{#isString}}JsonSupport.of_string{{/isString}}{{#isLong}}JsonSupport.of_int64{{/isLong}}{{#isInteger}}JsonSupport.of_int32{{/isInteger}}{{#isFloat}}JsonSupport.of_float{{/isFloat}}{{#isNumber}}JsonSupport.of_float{{/isNumber}}{{#isDouble}}JsonSupport.of_float{{/isDouble}}{{#isBoolean}}JsonSupport.of_bool{{/isBoolean}}{{^isEnum}}{{#isModel}}{{#vendorExtensions.x-modelModule}}{{{vendorExtensions.x-modelModule}}}.to_yojson{{/vendorExtensions.x-modelModule}}{{^vendorExtensions.x-modelModule}}{{{baseType}}}.to_yojson{{/vendorExtensions.x-modelModule}}{{/isModel}}{{/isEnum}}{{^isModel}}{{^isContainer}}{{#isEnum}}Enums.{{{datatypeWithEnum}}}_to_yojson{{/isEnum}}{{/isContainer}}{{/isModel}} \ No newline at end of file +{{#isListContainer}}{{#items}}(JsonSupport.of_list_of {{> to_json}}){{/items}}{{/isListContainer}}{{#isMapContainer}}{{#items}}(JsonSupport.of_map_of {{> to_json}}){{/items}}{{/isMapContainer}}{{#isString}}JsonSupport.of_string{{/isString}}{{#isLong}}JsonSupport.of_int64{{/isLong}}{{#isInteger}}JsonSupport.of_int32{{/isInteger}}{{#isFloat}}JsonSupport.of_float{{/isFloat}}{{#isNumber}}JsonSupport.of_float{{/isNumber}}{{#isDouble}}JsonSupport.of_float{{/isDouble}}{{#isBoolean}}JsonSupport.of_bool{{/isBoolean}}{{^isEnum}}{{#isModel}}{{#vendorExtensions.x-model-module}}{{{vendorExtensions.x-model-module}}}.to_yojson{{/vendorExtensions.x-model-module}}{{^vendorExtensions.x-model-module}}{{{baseType}}}.to_yojson{{/vendorExtensions.x-model-module}}{{/isModel}}{{/isEnum}}{{^isModel}}{{^isContainer}}{{#isEnum}}Enums.{{{datatypeWithEnum}}}_to_yojson{{/isEnum}}{{/isContainer}}{{/isModel}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/ocaml/to_string.mustache b/modules/openapi-generator/src/main/resources/ocaml/to_string.mustache index 0588ac5ab4f8..3b41569d43d9 100644 --- a/modules/openapi-generator/src/main/resources/ocaml/to_string.mustache +++ b/modules/openapi-generator/src/main/resources/ocaml/to_string.mustache @@ -1 +1 @@ -{{#isContainer}}{{#items}}(List.map {{> to_string}}){{/items}}{{/isContainer}}{{^isEnum}}{{#isLong}}Int64.to_string{{/isLong}}{{#isInteger}}Int32.to_string{{/isInteger}}{{#isFloat}}string_of_float{{/isFloat}}{{#isNumber}}string_of_float{{/isNumber}}{{#isDouble}}string_of_float{{/isDouble}}{{#isBoolean}}string_of_bool{{/isBoolean}}{{#isFile}}(fun x -> x){{/isFile}}{{#isDate}}(fun x -> x){{/isDate}}{{#isDateTime}}(fun x -> x){{/isDateTime}}{{#isString}}(fun x -> x){{/isString}}{{#isByteArray}}(fun x -> x){{/isByteArray}}{{#isModel}}{{{vendorExtensions.x-modelModule}}}.show{{/isModel}}{{/isEnum}}{{^isModel}}{{^isContainer}}{{#isEnum}}Enums.show_{{{datatypeWithEnum}}}{{/isEnum}}{{/isContainer}}{{/isModel}} \ No newline at end of file +{{#isContainer}}{{#items}}(List.map {{> to_string}}){{/items}}{{/isContainer}}{{^isEnum}}{{#isLong}}Int64.to_string{{/isLong}}{{#isInteger}}Int32.to_string{{/isInteger}}{{#isFloat}}string_of_float{{/isFloat}}{{#isNumber}}string_of_float{{/isNumber}}{{#isDouble}}string_of_float{{/isDouble}}{{#isBoolean}}string_of_bool{{/isBoolean}}{{#isFile}}(fun x -> x){{/isFile}}{{#isDate}}(fun x -> x){{/isDate}}{{#isDateTime}}(fun x -> x){{/isDateTime}}{{#isString}}(fun x -> x){{/isString}}{{#isByteArray}}(fun x -> x){{/isByteArray}}{{#isModel}}{{{vendorExtensions.x-model-module}}}.show{{/isModel}}{{/isEnum}}{{^isModel}}{{^isContainer}}{{#isEnum}}Enums.show_{{{datatypeWithEnum}}}{{/isEnum}}{{/isContainer}}{{/isModel}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/rust-server/README.mustache b/modules/openapi-generator/src/main/resources/rust-server/README.mustache index f75899a2e493..bb8fe72a7491 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/README.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/README.mustache @@ -68,9 +68,9 @@ To run a client, follow one of the following simple steps: {{#operations}} {{#operation}} {{#vendorExtensions}} - {{^noClientExample}} + {{^x-no-client-example}} cargo run --example client {{{operationId}}} - {{/noClientExample}} + {{/x-no-client-example}} {{/vendorExtensions}} {{/operation}} {{/operations}} diff --git a/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache b/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache index 33d3bd68c14a..dbc63930c2d0 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/client-callbacks.mustache @@ -58,7 +58,7 @@ impl RequestParser for ApiRequestParser { {{#urls}} {{#requests}} // {{{operationId}}} - {{{httpMethod}}} {{{path}}} - &hyper::Method::{{{vendorExtensions.HttpMethod}}} if path.matched(paths::ID_{{{vendorExtensions.PATH_ID}}}) => Ok("{{{operationId}}}"), + &hyper::Method::{{{vendorExtensions.x-http-method}}} if path.matched(paths::ID_{{{vendorExtensions.x-path-id}}}) => Ok("{{{operationId}}}"), {{/requests}} {{/urls}} {{/callbacks}} diff --git a/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache b/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache index cc65e176ac58..561b92a646bb 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/client-operation.mustache @@ -1,9 +1,9 @@ - fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}( + fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( &self, {{#vendorExtensions}} - {{#callbackParams}} + {{#x-callback-params}} callback_{{.}}: String, - {{/callbackParams}} + {{/x-callback-params}} {{/vendorExtensions}} {{#allParams}} param_{{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}}, @@ -22,9 +22,9 @@ ,{{{paramName}}}=utf8_percent_encode(¶m_{{{paramName}}}.to_string(), ID_ENCODE_SET) {{/pathParams}} {{#vendorExtensions}} - {{#callbackParams}} + {{#x-callback-params}} ,{{.}}=callback_{{.}} - {{/callbackParams}} + {{/x-callback-params}} {{/vendorExtensions}} ); @@ -62,7 +62,7 @@ }; let mut request = match hyper::Request::builder() - .method("{{{vendorExtensions.HttpMethod}}}") + .method("{{{vendorExtensions.x-http-method}}}") .uri(uri) .body(Body::empty()) { Ok(req) => req, @@ -70,7 +70,7 @@ }; {{#vendorExtensions}} - {{#consumesMultipart}} + {{#x-consumes-multipart}} let mut multipart = Multipart::new(); {{#vendorExtensions}} @@ -130,10 +130,10 @@ Err(e) => return Box::new(future::err(ApiError(format!("Unable to create header: {} - {}", multipart_header, e)))) }); - {{/consumesMultipart}} - {{^consumesMultipart}} + {{/x-consumes-multipart}} + {{^x-consumes-multipart}} {{#vendorExtensions}} - {{^consumesMultipartRelated}} + {{^x-consumes-multipart-related}} {{#formParams}} {{#-first}} let params = &[ @@ -151,8 +151,8 @@ *request.body_mut() = Body::from(body.into_bytes()); {{/-last}} {{/formParams}} - {{/consumesMultipartRelated}} - {{#consumesMultipartRelated}} + {{/x-consumes-multipart-related}} + {{#x-consumes-multipart-related}} {{#formParams}} {{#-first}} // Construct the Body for a multipart/related request. The mime 0.2.6 library @@ -214,37 +214,37 @@ {{/-last}} {{/formParams}} - {{/consumesMultipartRelated}} + {{/x-consumes-multipart-related}} {{/vendorExtensions}} {{#bodyParam}} {{#-first}} // Body parameter {{/-first}} {{#vendorExtensions}} - {{#consumesPlainText}} + {{#x-consumes-plain-text}} {{#isByteArray}} let body = param_{{{paramName}}}.0; {{/isByteArray}} {{^isByteArray}} let body = param_{{{paramName}}}; {{/isByteArray}} - {{/consumesPlainText}} + {{/x-consumes-plain-text}} {{#required}} - {{#consumesXml}} + {{#x-consumes-xml}} let body = param_{{{paramName}}}.to_xml(); - {{/consumesXml}} - {{#consumesJson}} + {{/x-consumes-xml}} + {{#x-consumes-json}} let body = serde_json::to_string(¶m_{{{paramName}}}).expect("impossible to fail to serialize"); - {{/consumesJson}} + {{/x-consumes-json}} {{/required}} {{^required}} let body = param_{{{paramName}}}.map(|ref body| { - {{#consumesXml}} + {{#x-consumes-xml}} body.to_xml() - {{/consumesXml}} - {{#consumesJson}} + {{/x-consumes-xml}} + {{#x-consumes-json}} serde_json::to_string(body).expect("impossible to fail to serialize") - {{/consumesJson}} + {{/x-consumes-json}} }); {{/required}} {{/vendorExtensions}} @@ -270,7 +270,7 @@ {{/-last}} {{/bodyParam}} -{{/consumesMultipart}} +{{/x-consumes-multipart}} {{/vendorExtensions}} let header = HeaderValue::from_str((context as &dyn Has).get().0.clone().to_string().as_str()); request.headers_mut().insert(HeaderName::from_static("x-span-id"), match header { @@ -384,32 +384,32 @@ .map_err(|e| ApiError(format!("Failed to read response: {}", e))) .and_then(|body| {{#vendorExtensions}} -{{#producesBytes}} +{{#x-produces-bytes}} Ok(swagger::ByteArray(body.to_vec())) -{{/producesBytes}} -{{^producesBytes}} +{{/x-produces-bytes}} +{{^x-produces-bytes}} str::from_utf8(&body) .map_err(|e| ApiError(format!("Response was not valid UTF8: {}", e))) .and_then(|body| - {{#producesXml}} + {{#x-produces-xml}} // ToDo: this will move to swagger-rs and become a standard From conversion trait // once https://github.com/RReverser/serde-xml-rs/pull/45 is accepted upstream serde_xml_rs::from_str::<{{{dataType}}}>(body) .map_err(|e| ApiError(format!("Response body did not match the schema: {}", e))) - {{/producesXml}} - {{#producesJson}} + {{/x-produces-xml}} + {{#x-produces-json}} serde_json::from_str::<{{{dataType}}}>(body) .map_err(|e| e.into()) - {{/producesJson}} - {{#producesPlainText}} + {{/x-produces-json}} + {{#x-produces-plain-text}} Ok(body.to_string()) - {{/producesPlainText}} + {{/x-produces-plain-text}} ) -{{/producesBytes}} +{{/x-produces-bytes}} {{/vendorExtensions}} ) .map(move |body| { - {{{operationId}}}Response::{{#vendorExtensions}}{{x-responseId}}{{/vendorExtensions}} + {{{operationId}}}Response::{{#vendorExtensions}}{{x-response-id}}{{/vendorExtensions}} {{^headers}} (body) {{/headers}} @@ -427,7 +427,7 @@ {{/dataType}} {{^dataType}} future::ok( - {{{operationId}}}Response::{{#vendorExtensions}}{{x-responseId}}{{/vendorExtensions}} + {{{operationId}}}Response::{{#vendorExtensions}}{{x-response-id}}{{/vendorExtensions}} {{#headers}} {{#-first}} { diff --git a/modules/openapi-generator/src/main/resources/rust-server/example-client-main.mustache b/modules/openapi-generator/src/main/resources/rust-server/example-client-main.mustache index b1f7bbeee959..b4bfacdcce6b 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/example-client-main.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/example-client-main.mustache @@ -34,9 +34,9 @@ fn main() { {{#operations}} {{#operation}} {{#vendorExtensions}} - {{^noClientExample}} + {{^x-no-client-example}} "{{{operationId}}}", - {{/noClientExample}} + {{/x-no-client-example}} {{/vendorExtensions}} {{/operation}} {{/operations}} @@ -95,22 +95,22 @@ fn main() { {{#operations}} {{#operation}} {{#vendorExtensions}} - {{#noClientExample}} + {{#x-no-client-example}} /* Disabled because there's no example. - {{/noClientExample}} + {{/x-no-client-example}} {{/vendorExtensions}} Some("{{{operationId}}}") => { - let result = rt.block_on(client.{{{vendorExtensions.operation_id}}}( + let result = rt.block_on(client.{{{vendorExtensions.x-operation-id}}}( {{#allParams}} - {{{vendorExtensions.example}}}{{^-last}},{{/-last}} + {{{vendorExtensions.x-example}}}{{^-last}},{{/-last}} {{/allParams}} )); info!("{:?} (X-Span-ID: {:?})", result, (client.context() as &dyn Has).get().clone()); }, {{#vendorExtensions}} - {{#noClientExample}} + {{#x-no-client-example}} */ - {{/noClientExample}} + {{/x-no-client-example}} {{/vendorExtensions}} {{/operation}} {{/operations}} diff --git a/modules/openapi-generator/src/main/resources/rust-server/example-server-operation.mustache b/modules/openapi-generator/src/main/resources/rust-server/example-server-operation.mustache index f7b1aaa66d07..744ca9686e3c 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/example-server-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/example-server-operation.mustache @@ -1,12 +1,12 @@ {{#summary}} /// {{{summary}}} {{/summary}} - fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}( + fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( &self, {{#vendorExtensions}} - {{#callbackParams}} + {{#x-callback-params}} callback_{{.}}: String, - {{/callbackParams}} + {{/x-callback-params}} {{/vendorExtensions}} {{#allParams}} {{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}}, @@ -14,6 +14,6 @@ context: &C) -> Box + Send> { let context = context.clone(); - info!("{{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}({{#allParams}}{{#vendorExtensions}}{{{formatString}}}{{/vendorExtensions}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) - X-Span-ID: {:?}"{{#allParams}}, {{{paramName}}}{{/allParams}}, context.get().0.clone()); + info!("{{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}({{#allParams}}{{#vendorExtensions}}{{{x-format-string}}}{{/vendorExtensions}}{{#hasMore}}, {{/hasMore}}{{/allParams}}) - X-Span-ID: {:?}"{{#allParams}}, {{{paramName}}}{{/allParams}}, context.get().0.clone()); Box::new(future::err("Generic failure".into())) } diff --git a/modules/openapi-generator/src/main/resources/rust-server/lib.mustache b/modules/openapi-generator/src/main/resources/rust-server/lib.mustache index e5135683f451..fa0505d55826 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/lib.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/lib.mustache @@ -31,7 +31,7 @@ pub trait Api { {{#summary}} /// {{{summary}}} {{/summary}} - fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}( + fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( &self, {{#allParams}} {{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}}, @@ -53,7 +53,7 @@ pub trait ApiNoContext { {{#summary}} /// {{{summary}}} {{/summary}} - fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}( + fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( &self, {{#allParams}} {{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}}, @@ -86,14 +86,14 @@ impl<'a, T: Api, C> ApiNoContext for ContextWrapper<'a, T, C> { {{#summary}} /// {{{summary}}} {{/summary}} - fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}( + fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( &self, {{#allParams}} {{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}}, {{/allParams}} ) -> Box + Send> { - self.api().{{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}({{#allParams}}{{{paramName}}}, {{/allParams}}&self.context()) + self.api().{{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}({{#allParams}}{{{paramName}}}, {{/allParams}}&self.context()) } {{/operation}} @@ -131,12 +131,12 @@ pub trait CallbackApi { {{#summary}} /// {{{summary}}} {{/summary}} - fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}( + fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( &self, {{#vendorExtensions}} - {{#callbackParams}} + {{#x-callback-params}} callback_{{.}}: String, - {{/callbackParams}} + {{/x-callback-params}} {{/vendorExtensions}} {{#allParams}} {{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}}, @@ -164,12 +164,12 @@ pub trait CallbackApiNoContext { {{#summary}} /// {{{summary}}} {{/summary}} - fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}( + fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( &self, {{#vendorExtensions}} - {{#callbackParams}} + {{#x-callback-params}} callback_{{.}}: String, - {{/callbackParams}} + {{/x-callback-params}} {{/vendorExtensions}} {{#allParams}} {{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}}, @@ -208,23 +208,23 @@ impl<'a, T: CallbackApi, C> CallbackApiNoContext for ContextWrapper<'a, T, C> {{#summary}} /// {{{summary}}} {{/summary}} - fn {{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}( + fn {{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( &self, {{#vendorExtensions}} - {{#callbackParams}} + {{#x-callback-params}} callback_{{.}}: String, - {{/callbackParams}} + {{/x-callback-params}} {{/vendorExtensions}} {{#allParams}} {{{paramName}}}: {{^required}}Option<{{/required}}{{#isListContainer}}&{{/isListContainer}}{{{dataType}}}{{^required}}>{{/required}}, {{/allParams}} ) -> Box + Send> { - self.api().{{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}( + self.api().{{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( {{#vendorExtensions}} - {{#callbackParams}} + {{#x-callback-params}} callback_{{.}}, - {{/callbackParams}} + {{/x-callback-params}} {{/vendorExtensions}} {{#allParams}} {{{paramName}}}, diff --git a/modules/openapi-generator/src/main/resources/rust-server/models.mustache b/modules/openapi-generator/src/main/resources/rust-server/models.mustache index 58618bef5ff8..63bc8e469c87 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/models.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/models.mustache @@ -159,25 +159,25 @@ impl std::convert::TryFrom for header::IntoHeaderVal } } -{{#arrayModelType}}{{#vendorExtensions}}{{#itemXmlName}}// Utility function for wrapping list elements when serializing xml +{{#arrayModelType}}{{#vendorExtensions}}{{#x-item-xml-name}}// Utility function for wrapping list elements when serializing xml #[allow(non_snake_case)] -fn wrap_in_{{{itemXmlName}}}(item: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result +fn wrap_in_{{{x-item-xml-name}}}(item: &Vec<{{{arrayModelType}}}>, serializer: S) -> std::result::Result where S: serde::ser::Serializer, { - serde_xml_rs::wrap_primitives(item, serializer, "{{{itemXmlName}}}") + serde_xml_rs::wrap_primitives(item, serializer, "{{{x-item-xml-name}}}") } -{{/itemXmlName}} +{{/x-item-xml-name}} {{/vendorExtensions}} {{! vec}} #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)] #[cfg_attr(feature = "conversion", derive(frunk::LabelledGeneric))] pub struct {{{classname}}}( {{#vendorExtensions}} -{{#itemXmlName}} - #[serde(serialize_with = "wrap_in_{{{itemXmlName}}}")] -{{/itemXmlName}} +{{#x-item-xml-name}} + #[serde(serialize_with = "wrap_in_{{{x-item-xml-name}}}")] +{{/x-item-xml-name}} {{/vendorExtensions}} Vec<{{{arrayModelType}}}> ); @@ -277,9 +277,9 @@ pub struct {{{classname}}} { {{/isEnum}} #[serde(rename = "{{{baseName}}}")] {{#vendorExtensions}} -{{#itemXmlName}} - #[serde(serialize_with = "wrap_in_{{{itemXmlName}}}")] -{{/itemXmlName}} +{{#x-item-xml-name}} + #[serde(serialize_with = "wrap_in_{{{x-item-xml-name}}}")] +{{/x-item-xml-name}} {{/vendorExtensions}} {{#required}} pub {{{name}}}: {{#isNullable}}swagger::Nullable<{{/isNullable}}{{{dataType}}}{{#isNullable}}>{{/isNullable}}, @@ -478,4 +478,4 @@ impl {{{classname}}} { } {{/usesXml}} {{/model}} -{{/models}} +{{/models}} \ No newline at end of file diff --git a/modules/openapi-generator/src/main/resources/rust-server/response.mustache b/modules/openapi-generator/src/main/resources/rust-server/response.mustache index 3e4bc94494a3..ca2dbe7a6a6c 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/response.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/response.mustache @@ -1,13 +1,13 @@ #[derive(Debug, PartialEq)] -{{#vendorExtensions.x-mustUseResponse}} +{{#vendorExtensions.x-must-use-response}} #[must_use] -{{/vendorExtensions.x-mustUseResponse}} +{{/vendorExtensions.x-must-use-response}} pub enum {{{operationId}}}Response { {{#responses}} {{#message}} /// {{{message}}}{{/message}} {{#vendorExtensions}} - {{{x-responseId}}} + {{{x-response-id}}} {{/vendorExtensions}} {{^dataType}} {{#hasHeaders}} @@ -17,23 +17,23 @@ pub enum {{{operationId}}}Response { {{#dataType}} {{^hasHeaders}} {{#vendorExtensions}} - {{#producesPlainText}} + {{#x-produces-plain-text}} (String) - {{/producesPlainText}} - {{^producesPlainText}} + {{/x-produces-plain-text}} + {{^x-produces-plain-text}} ({{{dataType}}}) - {{/producesPlainText}} + {{/x-produces-plain-text}} {{/vendorExtensions}} {{/hasHeaders}} {{#hasHeaders}} { {{#vendorExtensions}} - {{#producesPlainText}} + {{#x-produces-plain-text}} body: String, - {{/producesPlainText}} - {{^producesPlainText}} + {{/x-produces-plain-text}} + {{^x-produces-plain-text}} body: {{{dataType}}}, - {{/producesPlainText}} + {{/x-produces-plain-text}} {{/vendorExtensions}} {{/hasHeaders}} {{/dataType}} diff --git a/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache b/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache index cbb011fe9a3e..013d9c4f52d7 100644 --- a/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache +++ b/modules/openapi-generator/src/main/resources/rust-server/server-operation.mustache @@ -38,7 +38,7 @@ {{/hasAuthMethods}} {{#vendorExtensions}} - {{#consumesMultipart}} + {{#x-consumes-multipart}} let boundary = match swagger::multipart::boundary(&headers) { Some(boundary) => boundary.to_string(), None => return Box::new(future::ok(Response::builder() @@ -47,8 +47,8 @@ .expect("Unable to create Bad Request response for incorrect boundary"))), }; - {{/consumesMultipart}} - {{#hasPathParams}} + {{/x-consumes-multipart}} + {{#x-has-path-params}} // Path parameters let path: &str = &uri.path().to_string(); let path_params = @@ -58,7 +58,7 @@ panic!("Path {} matched RE {{{x-path-id}}} in set but failed match against \"{}\"", path, paths::REGEX_{{{x-path-id}}}.as_str()) ); - {{/hasPathParams}} + {{/x-has-path-params}} {{/vendorExtensions}} {{#pathParams}} let param_{{{paramName}}} = match percent_encoding::percent_decode(path_params["{{{baseName}}}"].as_bytes()).decode_utf8() { @@ -77,9 +77,9 @@ {{/pathParams}} {{#vendorExtensions}} - {{#callbackParams}} + {{#x-callback-params}} let callback_{{.}} = path_params["{{{.}}}"].to_string(); - {{/callbackParams}} + {{/x-callback-params}} {{/vendorExtensions}} {{#headerParams}} {{#-first}} @@ -163,7 +163,7 @@ {{/-last}} {{/queryParams}} {{#vendorExtensions}} -{{^consumesMultipart}} +{{^x-consumes-multipart}} {{#bodyParams}} {{#-first}} // Body parameters (note that non-required body parameters will ignore garbage @@ -174,17 +174,17 @@ match result { Ok(body) => { {{#vendorExtensions}} -{{^consumesPlainText}} +{{^x-consumes-plain-text}} let mut unused_elements = Vec::new(); -{{/consumesPlainText}} +{{/x-consumes-plain-text}} let param_{{{paramName}}}: Option<{{{dataType}}}> = if !body.is_empty() { -{{#consumesXml}} +{{#x-consumes-xml}} let deserializer = &mut serde_xml_rs::de::Deserializer::new_from_reader(&*body); -{{/consumesXml}} -{{#consumesJson}} +{{/x-consumes-xml}} +{{#x-consumes-json}} let deserializer = &mut serde_json::Deserializer::from_slice(&*body); -{{/consumesJson}} -{{^consumesPlainText}} +{{/x-consumes-json}} +{{^x-consumes-plain-text}} match serde_ignored::deserialize(deserializer, |path| { warn!("Ignoring unknown field in body: {}", path); unused_elements.push(path.to_string()); @@ -200,8 +200,8 @@ Err(_) => None, {{/required}} } -{{/consumesPlainText}} -{{#consumesPlainText}} +{{/x-consumes-plain-text}} +{{#x-consumes-plain-text}} {{#isByteArray}} Some(swagger::ByteArray(body.to_vec())) {{/isByteArray}} @@ -214,7 +214,7 @@ .expect("Unable to create Bad Request response for invalid body parameter {{{baseName}}} due to UTF-8"))), } {{/isString}} -{{/consumesPlainText}} +{{/x-consumes-plain-text}} {{/vendorExtensions}} } else { None @@ -233,8 +233,8 @@ {{/-last}} {{/bodyParams}} -{{/consumesMultipart}} -{{#consumesMultipart}} +{{/x-consumes-multipart}} +{{#x-consumes-multipart}} {{^bodyParams}} {{#vendorExtensions}} // Form Body parameters (note that non-required body parameters will ignore garbage @@ -308,9 +308,9 @@ {{/formParams}} {{/vendorExtensions}} {{/bodyParams}} -{{/consumesMultipart}} -{{^consumesMultipartRelated}} -{{^consumesMultipart}} +{{/x-consumes-multipart}} +{{^x-consumes-multipart-related}} +{{^x-consumes-multipart}} {{^bodyParams}} {{#vendorExtensions}} Box::new({ @@ -319,16 +319,16 @@ {{#-first}} // Form parameters {{/-first}} - let param_{{{paramName}}} = {{^isContainer}}{{#vendorExtensions}}{{{example}}};{{/vendorExtensions}}{{/isContainer}}{{#isListContainer}}{{#required}}Vec::new();{{/required}}{{^required}}None;{{/required}}{{/isListContainer}}{{#isMapContainer}}None;{{/isMapContainer}} + let param_{{{paramName}}} = {{^isContainer}}{{#vendorExtensions}}{{{x-example}}};{{/vendorExtensions}}{{/isContainer}}{{#isListContainer}}{{#required}}Vec::new();{{/required}}{{^required}}None;{{/required}}{{/isListContainer}}{{#isMapContainer}}None;{{/isMapContainer}} {{#-last}} {{/-last}} {{/formParams}} {{/vendorExtensions}} {{/bodyParams}} -{{/consumesMultipart}} -{{/consumesMultipartRelated}} -{{#consumesMultipartRelated}} +{{/x-consumes-multipart}} +{{/x-consumes-multipart-related}} +{{#x-consumes-multipart-related}} // Body parameters (note that non-required body parameters will ignore garbage // values, rather than causing a 400 response). Produce warning header and logs for // any unused fields. @@ -437,14 +437,14 @@ {{/-last}} {{/formParams}} -{{/consumesMultipartRelated}} +{{/x-consumes-multipart-related}} {{/vendorExtensions}} Box::new( - api_impl.{{#vendorExtensions}}{{{operation_id}}}{{/vendorExtensions}}( + api_impl.{{#vendorExtensions}}{{{x-operation-id}}}{{/vendorExtensions}}( {{#vendorExtensions}} - {{#callbackParams}} + {{#x-callback-params}} callback_{{.}}, - {{/callbackParams}} + {{/x-callback-params}} {{/vendorExtensions}} {{#allParams}} param_{{{paramName}}}{{#isListContainer}}.as_ref(){{/isListContainer}}, @@ -459,7 +459,7 @@ {{#bodyParams}} {{#vendorExtensions}} -{{^consumesPlainText}} +{{^x-consumes-plain-text}} if !unused_elements.is_empty() { response.headers_mut().insert( HeaderName::from_static("warning"), @@ -467,13 +467,13 @@ .expect("Unable to create Warning header value")); } -{{/consumesPlainText}} +{{/x-consumes-plain-text}} {{/vendorExtensions}} {{/bodyParams}} match result { Ok(rsp) => match rsp { {{#responses}} - {{{operationId}}}Response::{{#vendorExtensions}}{{x-responseId}}{{/vendorExtensions}} + {{{operationId}}}Response::{{#vendorExtensions}}{{x-response-id}}{{/vendorExtensions}} {{#dataType}} {{^headers}} (body) @@ -526,35 +526,35 @@ {{#vendorExtensions}} response.headers_mut().insert( CONTENT_TYPE, - HeaderValue::from_str("{{{mimeType}}}") - .expect("Unable to create Content-Type header for {{{uppercase_operation_id}}}_{{x-uppercaseResponseId}}")); + HeaderValue::from_str("{{{x-mime-type}}}") + .expect("Unable to create Content-Type header for {{{x-uppercase-operation-id}}}_{{x-uppercase-response-id}}")); {{/vendorExtensions}} {{/dataType}} {{/-first}} {{/produces}} {{#dataType}} {{#vendorExtensions}} -{{#producesXml}} -{{^has_namespace}} +{{#x-produces-xml}} +{{^x-has-namespace}} let body = serde_xml_rs::to_string(&body).expect("impossible to fail to serialize"); -{{/has_namespace}} -{{#has_namespace}} +{{/x-has-namespace}} +{{#x-has-namespace}} let mut namespaces = std::collections::BTreeMap::new(); // An empty string is used to indicate a global namespace in xmltree. namespaces.insert("".to_string(), {{{dataType}}}::NAMESPACE.to_string()); let body = serde_xml_rs::to_string_with_namespaces(&body, namespaces).expect("impossible to fail to serialize"); -{{/has_namespace}} -{{/producesXml}} -{{#producesJson}} +{{/x-has-namespace}} +{{/x-produces-xml}} +{{#x-produces-json}} let body = serde_json::to_string(&body).expect("impossible to fail to serialize"); -{{/producesJson}} -{{#producesBytes}} +{{/x-produces-json}} +{{#x-produces-bytes}} let body = body.0; -{{/producesBytes}} -{{#producesPlainText}} +{{/x-produces-bytes}} +{{#x-produces-plain-text}} let body = body; -{{/producesPlainText}} +{{/x-produces-plain-text}} {{/vendorExtensions}} *response.body_mut() = Body::from(body); {{/dataType}} @@ -573,10 +573,10 @@ } )) {{#vendorExtensions}} -{{^consumesMultipart}} +{{^x-consumes-multipart}} {{^bodyParams}} {{#vendorExtensions}} -{{#consumesMultipartRelated}} +{{#x-consumes-multipart-related}} }, Err(e) => Box::new(future::ok(Response::builder() .status(StatusCode::BAD_REQUEST) @@ -585,14 +585,14 @@ } }) ) as Self::Future -{{/consumesMultipartRelated}} -{{^consumesMultipartRelated}} +{{/x-consumes-multipart-related}} +{{^x-consumes-multipart-related}} }} }) as Self::Future -{{/consumesMultipartRelated}} +{{/x-consumes-multipart-related}} {{/vendorExtensions}} {{/bodyParams}} -{{/consumesMultipart}} +{{/x-consumes-multipart}} {{/vendorExtensions}} {{#bodyParams}} {{#-first}} @@ -607,7 +607,7 @@ {{/-first}} {{/bodyParams}} {{#vendorExtensions}} -{{#consumesMultipart}} +{{#x-consumes-multipart}} {{^bodyParams}} {{#vendorExtensions}} as Self::Future @@ -621,6 +621,6 @@ ) {{/vendorExtensions}} {{/bodyParams}} -{{/consumesMultipart}} +{{/x-consumes-multipart}} {{/vendorExtensions}} }, diff --git a/modules/openapi-generator/src/main/resources/rust/model.mustache b/modules/openapi-generator/src/main/resources/rust/model.mustache index dab429fdeb37..c845b7d2cf8a 100644 --- a/modules/openapi-generator/src/main/resources/rust/model.mustache +++ b/modules/openapi-generator/src/main/resources/rust/model.mustache @@ -24,7 +24,7 @@ pub enum {{classname}} { #[serde(tag = "{{{vendorExtensions.x-tag-name}}}")] pub enum {{classname}} { {{#vendorExtensions}} - {{#mappedModels}} + {{#x-mapped-models}} #[serde(rename="{{mappingName}}")] {{modelName}} { {{#vars}} @@ -35,7 +35,7 @@ pub enum {{classname}} { {{{name}}}: {{#required}}{{#isNullable}}Option<{{/isNullable}}{{/required}}{{^required}}Option<{{/required}}{{#isEnum}}{{{enumName}}}{{/isEnum}}{{^isEnum}}{{{dataType}}}{{/isEnum}}{{#required}}{{#isNullable}}>{{/isNullable}}{{/required}}{{^required}}>{{/required}}, {{/vars}} }, - {{/mappedModels}} + {{/x-mapped-models}} {{/vendorExtensions}} } From 4408b951b46ef9a37e7591a0851c173349bc1bee Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sun, 26 Apr 2020 21:58:28 -0400 Subject: [PATCH 05/16] Set remaining vendor extensions to convention of lower kebab-cased with x- prefix --- .../openapitools/codegen/languages/OCamlClientCodegen.java | 2 +- .../PhpZendExpressivePathHandlerServerCodegen.java | 1 + .../openapitools/codegen/languages/RustServerCodegen.java | 7 ++++--- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java index ff447d1b4dff..619c4c8d6e3b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/OCamlClientCodegen.java @@ -45,7 +45,7 @@ public class OCamlClientCodegen extends DefaultCodegen implements CodegenConfig public static final String PACKAGE_NAME = "packageName"; public static final String PACKAGE_VERSION = "packageVersion"; - static final String X_MODEL_MODULE = "x-modelModule"; + static final String X_MODEL_MODULE = "x-model-module"; public static final String CO_HTTP = "cohttp"; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpZendExpressivePathHandlerServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpZendExpressivePathHandlerServerCodegen.java index 39732835cf91..ee2099b6af89 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpZendExpressivePathHandlerServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PhpZendExpressivePathHandlerServerCodegen.java @@ -36,6 +36,7 @@ public class PhpZendExpressivePathHandlerServerCodegen extends AbstractPhpCodegen { private static final Logger LOGGER = LoggerFactory.getLogger(PhpZendExpressivePathHandlerServerCodegen.class); + // TODO: Rename to x- prefixed vendor extensions, per specification. public static final String VEN_FROM_QUERY = "internal.ze-ph.fromQuery"; public static final String VEN_COLLECTION_FORMAT = "internal.ze-ph.collectionFormat"; public static final String VEN_QUERY_DATA_TYPE = "internal.ze-ph.queryDataType"; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java index 3ee9f53c48f2..cc6a1234923b 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java @@ -702,7 +702,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation hasPathParams = true; } - op.vendorExtensions.put("callbackParams", params); + op.vendorExtensions.put("x-callback-params", params); } // Save off the regular expression and path details in the relevant @@ -991,7 +991,7 @@ private void postProcessOperationWithModels(CodegenOperation op, List al additionalProperties.put("apiUsesMultipartFormData", true); additionalProperties.put("apiUsesMultipart", true); } else if (isMimetypeMultipartRelated(mediaType)) { - op.vendorExtensions.put("consumesMultipartRelated", true); + op.vendorExtensions.put("x-consumes-multipart-related", true); additionalProperties.put("apiUsesMultipartRelated", true); additionalProperties.put("apiUsesMultipart", true); } @@ -1574,9 +1574,10 @@ private void processParam(CodegenParameter param, CodegenOperation op) { } if (Boolean.TRUE.equals(param.isFreeFormObject)) { - param.vendorExtensions.put("formatString", "{:?}"); + param.vendorExtensions.put("x-format-string", "{:?}"); example = null; } else if (param.isString) { + param.vendorExtensions.put("x-format-string", "\\\"{}\\\""); example = "\"" + ((param.example != null) ? param.example : "") + "\".to_string()"; } else if (param.isPrimitiveType) { if ((param.isByteArray) || (param.isBinary)) { From 00861fb5ba2ddd383f2421c4f020ec446702ac48 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sun, 26 Apr 2020 21:58:36 -0400 Subject: [PATCH 06/16] [samples] Regenerate --- .../lib/OpenAPIPetstore/Model.hs | 6 +++--- .../haskell-servant/.openapi-generator/VERSION | 2 +- .../output/openapi-v3/src/client/callbacks.rs | 18 ------------------ 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs index 1331ed4b237d..53327dc686a3 100644 --- a/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs +++ b/samples/client/petstore/haskell-http-client/lib/OpenAPIPetstore/Model.hs @@ -2039,7 +2039,7 @@ toE'ArrayEnum = \case -- ** E'EnumFormString --- | Enum of 'Text' . +-- | Enum of 'Text' . -- Form parameter enum test (string) data E'EnumFormString = E'EnumFormString'_abc -- ^ @"_abc"@ @@ -2304,7 +2304,7 @@ toE'Kind = \case -- ** E'Status --- | Enum of 'Text' . +-- | Enum of 'Text' . -- Order Status data E'Status = E'Status'Placed -- ^ @"placed"@ @@ -2336,7 +2336,7 @@ toE'Status = \case -- ** E'Status2 --- | Enum of 'Text' . +-- | Enum of 'Text' . -- pet status in the store data E'Status2 = E'Status2'Available -- ^ @"available"@ diff --git a/samples/server/petstore/haskell-servant/.openapi-generator/VERSION b/samples/server/petstore/haskell-servant/.openapi-generator/VERSION index c3a2c7076fa8..d99e7162d01f 100644 --- a/samples/server/petstore/haskell-servant/.openapi-generator/VERSION +++ b/samples/server/petstore/haskell-servant/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.0-SNAPSHOT \ No newline at end of file +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs index 7ed0cb95aacf..2b48730d92ae 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs @@ -140,15 +140,6 @@ where // CallbackCallbackWithHeaderPost - POST /{$request.query.url}/callback-with-header &hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => { - // Path parameters - let path: &str = &uri.path().to_string(); - let path_params = - paths::REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER - .captures(&path) - .unwrap_or_else(|| - panic!("Path {} matched RE REQUEST_QUERY_URL_CALLBACK_WITH_HEADER in set but failed match against \"{}\"", path, paths::REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER.as_str()) - ); - let callback_request_query_url = path_params["request_query_url"].to_string(); // Header parameters let param_information = headers.get(HeaderName::from_static("information")); @@ -208,15 +199,6 @@ where // CallbackCallbackPost - POST /{$request.query.url}/callback &hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => { - // Path parameters - let path: &str = &uri.path().to_string(); - let path_params = - paths::REGEX_REQUEST_QUERY_URL_CALLBACK - .captures(&path) - .unwrap_or_else(|| - panic!("Path {} matched RE REQUEST_QUERY_URL_CALLBACK in set but failed match against \"{}\"", path, paths::REGEX_REQUEST_QUERY_URL_CALLBACK.as_str()) - ); - let callback_request_query_url = path_params["request_query_url"].to_string(); Box::new({ {{ From 5ff6f5221cec1945d72bd43a16596b6d0d614d45 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Thu, 7 May 2020 21:05:45 -0400 Subject: [PATCH 07/16] Update modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java Before we were adding hasPathParams twice, once with !op.pathParams.isEmpty(), and then again with hasPathParams. This was probably caused by a mistaken merge. This is causing the difference in samples Co-authored-by: Richard Whitehouse --- .../org/openapitools/codegen/languages/RustServerCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java index cc6a1234923b..3db43b17c62f 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/RustServerCodegen.java @@ -737,7 +737,7 @@ public CodegenOperation fromOperation(String path, String httpMethod, Operation String vendorExtensionPath = op.path.replace("{", ":").replace("}", ""); op.vendorExtensions.put("x-path",vendorExtensionPath); op.vendorExtensions.put("x-path-id", pathId); - op.vendorExtensions.put("x-has-path-params", !op.pathParams.isEmpty()); + op.vendorExtensions.put("x-has-path-params", hasPathParams); op.vendorExtensions.put("x-path-format-string", formatPath); String vendorExtensionHttpMethod = op.httpMethod.toUpperCase(Locale.ROOT); From 110d3318c594ecba74c7c882484dfa4b89e893b3 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Thu, 7 May 2020 21:43:04 -0400 Subject: [PATCH 08/16] [Samples] Regenerated! --- .../dart2/openapi/.openapi-generator/VERSION | 2 +- .../dart2/openapi/lib/api/pet_api.dart | 48 +++++++++---------- .../dart2/openapi/lib/api/store_api.dart | 24 +++++----- .../dart2/openapi/lib/api/user_api.dart | 48 +++++++++---------- .../dart2/openapi/lib/api_client.dart | 22 +++++---- .../server/petstore/jaxrs-jersey/README.md | 2 +- samples/server/petstore/jaxrs-jersey/pom.xml | 2 +- .../php-slim4/lib/Model/EnumClass.php | 4 +- .../output/openapi-v3/src/client/callbacks.rs | 18 +++++++ 9 files changed, 96 insertions(+), 74 deletions(-) diff --git a/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION b/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION index 71d2eb1c7fcd..d99e7162d01f 100644 --- a/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION +++ b/samples/client/petstore/dart2/openapi/.openapi-generator/VERSION @@ -1 +1 @@ -5.0.0-SNAPSHOT +5.0.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart b/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart index 2b00c7d63b73..a413df7b4242 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/pet_api.dart @@ -28,10 +28,10 @@ class PetApi { List contentTypes = ["application/json","application/xml"]; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = ["petstore_auth"]; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -46,7 +46,7 @@ class PetApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -86,10 +86,10 @@ class PetApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = ["petstore_auth"]; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -104,7 +104,7 @@ class PetApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -144,10 +144,10 @@ class PetApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = ["petstore_auth"]; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -162,7 +162,7 @@ class PetApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -203,10 +203,10 @@ class PetApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = ["petstore_auth"]; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -221,7 +221,7 @@ class PetApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -261,10 +261,10 @@ class PetApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = ["api_key"]; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -279,7 +279,7 @@ class PetApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -319,10 +319,10 @@ class PetApi { List contentTypes = ["application/json","application/xml"]; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = ["petstore_auth"]; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -337,7 +337,7 @@ class PetApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -376,10 +376,10 @@ class PetApi { List contentTypes = ["application/x-www-form-urlencoded"]; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = ["petstore_auth"]; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if (name != null) { @@ -406,7 +406,7 @@ class PetApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -445,10 +445,10 @@ class PetApi { List contentTypes = ["multipart/form-data"]; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = ["petstore_auth"]; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if (additionalMetadata != null) { @@ -474,7 +474,7 @@ class PetApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } diff --git a/samples/client/petstore/dart2/openapi/lib/api/store_api.dart b/samples/client/petstore/dart2/openapi/lib/api/store_api.dart index 3b48cbbc4a3b..10dc4a35b85a 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/store_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/store_api.dart @@ -28,10 +28,10 @@ class StoreApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -46,7 +46,7 @@ class StoreApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -82,10 +82,10 @@ class StoreApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = ["api_key"]; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -100,7 +100,7 @@ class StoreApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -141,10 +141,10 @@ class StoreApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -159,7 +159,7 @@ class StoreApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -199,10 +199,10 @@ class StoreApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -217,7 +217,7 @@ class StoreApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } diff --git a/samples/client/petstore/dart2/openapi/lib/api/user_api.dart b/samples/client/petstore/dart2/openapi/lib/api/user_api.dart index 5a35ba394c08..a940ca410713 100644 --- a/samples/client/petstore/dart2/openapi/lib/api/user_api.dart +++ b/samples/client/petstore/dart2/openapi/lib/api/user_api.dart @@ -28,10 +28,10 @@ class UserApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -46,7 +46,7 @@ class UserApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -85,10 +85,10 @@ class UserApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -103,7 +103,7 @@ class UserApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -142,10 +142,10 @@ class UserApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -160,7 +160,7 @@ class UserApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -199,10 +199,10 @@ class UserApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -217,7 +217,7 @@ class UserApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -256,10 +256,10 @@ class UserApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -274,7 +274,7 @@ class UserApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -319,10 +319,10 @@ class UserApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -337,7 +337,7 @@ class UserApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -374,10 +374,10 @@ class UserApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -392,7 +392,7 @@ class UserApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } @@ -434,10 +434,10 @@ class UserApi { List contentTypes = []; - String contentType = contentTypes.isNotEmpty ? contentTypes[0] : "application/json"; + String nullableContentType = contentTypes.isNotEmpty ? contentTypes[0] : null; List authNames = []; - if(contentType.startsWith("multipart/form-data")) { + if(nullableContentType != null && nullableContentType.startsWith("multipart/form-data")) { bool hasFields = false; MultipartRequest mp = MultipartRequest(null, null); if(hasFields) @@ -452,7 +452,7 @@ class UserApi { postBody, headerParams, formParams, - contentType, + nullableContentType, authNames); return response; } diff --git a/samples/client/petstore/dart2/openapi/lib/api_client.dart b/samples/client/petstore/dart2/openapi/lib/api_client.dart index 793ac6a73410..d68c9691879f 100644 --- a/samples/client/petstore/dart2/openapi/lib/api_client.dart +++ b/samples/client/petstore/dart2/openapi/lib/api_client.dart @@ -100,7 +100,7 @@ class ApiClient { Object body, Map headerParams, Map formParams, - String contentType, + String nullableContentType, List authNames) async { _updateParamsForAuth(authNames, queryParams, headerParams); @@ -116,7 +116,10 @@ class ApiClient { String url = basePath + path + queryString; headerParams.addAll(_defaultHeaderMap); - headerParams['Content-Type'] = contentType; + if (nullableContentType != null) { + final contentType = nullableContentType; + headerParams['Content-Type'] = contentType; + } if(body is MultipartRequest) { var request = MultipartRequest(method, Uri.parse(url)); @@ -127,20 +130,21 @@ class ApiClient { var response = await client.send(request); return Response.fromStream(response); } else { - var msgBody = contentType == "application/x-www-form-urlencoded" ? formParams : serialize(body); + var msgBody = nullableContentType == "application/x-www-form-urlencoded" ? formParams : serialize(body); + final nullableHeaderParams = (headerParams.isEmpty)? null: headerParams; switch(method) { case "POST": - return client.post(url, headers: headerParams, body: msgBody); + return client.post(url, headers: nullableHeaderParams, body: msgBody); case "PUT": - return client.put(url, headers: headerParams, body: msgBody); + return client.put(url, headers: nullableHeaderParams, body: msgBody); case "DELETE": - return client.delete(url, headers: headerParams); + return client.delete(url, headers: nullableHeaderParams); case "PATCH": - return client.patch(url, headers: headerParams, body: msgBody); + return client.patch(url, headers: nullableHeaderParams, body: msgBody); case "HEAD": - return client.head(url, headers: headerParams); + return client.head(url, headers: nullableHeaderParams); default: - return client.get(url, headers: headerParams); + return client.get(url, headers: nullableHeaderParams); } } } diff --git a/samples/server/petstore/jaxrs-jersey/README.md b/samples/server/petstore/jaxrs-jersey/README.md index 64a6c60dc38e..4d4b9499d449 100644 --- a/samples/server/petstore/jaxrs-jersey/README.md +++ b/samples/server/petstore/jaxrs-jersey/README.md @@ -17,7 +17,7 @@ mvn clean package jetty:run You can then view the OpenAPI v2 specification here: ``` -http://localhost:8080/v2/swagger.json +http://localhost:80/v2/swagger.json ``` Note that if you have configured the `host` to be something other than localhost, the calls through diff --git a/samples/server/petstore/jaxrs-jersey/pom.xml b/samples/server/petstore/jaxrs-jersey/pom.xml index ecfcfd15f7ad..a60e297f03f4 100644 --- a/samples/server/petstore/jaxrs-jersey/pom.xml +++ b/samples/server/petstore/jaxrs-jersey/pom.xml @@ -47,7 +47,7 @@ stopit 10 - 8080 + 80 60000 diff --git a/samples/server/petstore/php-slim4/lib/Model/EnumClass.php b/samples/server/petstore/php-slim4/lib/Model/EnumClass.php index c3998d8602c5..3ddd829b3137 100644 --- a/samples/server/petstore/php-slim4/lib/Model/EnumClass.php +++ b/samples/server/petstore/php-slim4/lib/Model/EnumClass.php @@ -30,8 +30,8 @@ class EnumClass implements ModelInterface private const MODEL_SCHEMA = <<<'SCHEMA' { "type" : "string", - "enum" : [ "_abc", "-efg", "(xyz)" ], - "default" : "-efg" + "default" : "-efg", + "enum" : [ "_abc", "-efg", "(xyz)" ] } SCHEMA; diff --git a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs index 2b48730d92ae..7ed0cb95aacf 100644 --- a/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs +++ b/samples/server/petstore/rust-server/output/openapi-v3/src/client/callbacks.rs @@ -140,6 +140,15 @@ where // CallbackCallbackWithHeaderPost - POST /{$request.query.url}/callback-with-header &hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER) => { + // Path parameters + let path: &str = &uri.path().to_string(); + let path_params = + paths::REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER + .captures(&path) + .unwrap_or_else(|| + panic!("Path {} matched RE REQUEST_QUERY_URL_CALLBACK_WITH_HEADER in set but failed match against \"{}\"", path, paths::REGEX_REQUEST_QUERY_URL_CALLBACK_WITH_HEADER.as_str()) + ); + let callback_request_query_url = path_params["request_query_url"].to_string(); // Header parameters let param_information = headers.get(HeaderName::from_static("information")); @@ -199,6 +208,15 @@ where // CallbackCallbackPost - POST /{$request.query.url}/callback &hyper::Method::POST if path.matched(paths::ID_REQUEST_QUERY_URL_CALLBACK) => { + // Path parameters + let path: &str = &uri.path().to_string(); + let path_params = + paths::REGEX_REQUEST_QUERY_URL_CALLBACK + .captures(&path) + .unwrap_or_else(|| + panic!("Path {} matched RE REQUEST_QUERY_URL_CALLBACK in set but failed match against \"{}\"", path, paths::REGEX_REQUEST_QUERY_URL_CALLBACK.as_str()) + ); + let callback_request_query_url = path_params["request_query_url"].to_string(); Box::new({ {{ From 51a47cc0a6705eba6713ec15ab9304119002237e Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sun, 10 May 2020 15:15:13 -0400 Subject: [PATCH 09/16] Fix -D conversion to additional-properties, missed in bat files --- bin/windows/android-petstore-httpclient.bat | 2 +- bin/windows/go-experimental-petstore.bat | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/bin/windows/android-petstore-httpclient.bat b/bin/windows/android-petstore-httpclient.bat index 181ec906a493..602d885e90ea 100755 --- a/bin/windows/android-petstore-httpclient.bat +++ b/bin/windows/android-petstore-httpclient.bat @@ -5,6 +5,6 @@ If Not Exist %executable% ( ) REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties -set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g android -o samples\client\petstore\android\httpclient -Dlibrary=httpclient +set ags=generate -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g android -o samples\client\petstore\android\httpclient --additional-properties library=httpclient java %JAVA_OPTS% -jar %executable% %ags% diff --git a/bin/windows/go-experimental-petstore.bat b/bin/windows/go-experimental-petstore.bat index 1a62e273e5d4..d4c7d1c23a5c 100755 --- a/bin/windows/go-experimental-petstore.bat +++ b/bin/windows/go-experimental-petstore.bat @@ -14,7 +14,7 @@ echo Removing files and folders under %STUB_DIR% del /F /S /Q %STUB_DIR% REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties -set ags=generate -t modules\openapi-generator\src\main\resources\%GENERATOR% -i %SPEC% -g %GENERATOR% -o %STUB_DIR% -DpackageName=petstore +set ags=generate -t modules\openapi-generator\src\main\resources\%GENERATOR% -i %SPEC% -g %GENERATOR% -o %STUB_DIR% --additional-properties packageName=petstore java %JAVA_OPTS% -jar %executable% %ags% From c59d5ac59629bb8ccfd1d1e7a188c5c258c287c9 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Thu, 14 May 2020 22:03:25 -0400 Subject: [PATCH 10/16] JERSEY2 option changed --- .../org/openapitools/codegen/languages/JavaClientCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java index 38fd11f04e9d..afa5d214dad1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java @@ -816,7 +816,7 @@ public Map postProcessModels(Map objs) { CodegenModel cm = (CodegenModel) mo.get("model"); cm.getVendorExtensions().putIfAbsent("x-implements", new ArrayList()); - if (JERSEY2_EXPERIMENTAL.equals(getLibrary())) { + if (JERSEY2.equals(getLibrary())) { cm.getVendorExtensions().put("x-implements", new ArrayList()); if (cm.oneOf != null && !cm.oneOf.isEmpty() && cm.oneOf.contains("ModelNull")) { From 746d14583618f204857aa92fa1e7fbde21899194 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Mon, 25 May 2020 10:09:50 -0400 Subject: [PATCH 11/16] [samples] Regenerate --- .../builds/composed-schemas/.openapi-generator/FILES | 7 +++++++ samples/server/petstore/jaxrs-jersey/README.md | 2 +- samples/server/petstore/jaxrs-jersey/pom.xml | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) create mode 100644 samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator/FILES diff --git a/samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator/FILES b/samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator/FILES new file mode 100644 index 000000000000..5bef353ae385 --- /dev/null +++ b/samples/client/petstore/typescript-axios/builds/composed-schemas/.openapi-generator/FILES @@ -0,0 +1,7 @@ +.gitignore +.npmignore +api.ts +base.ts +configuration.ts +git_push.sh +index.ts diff --git a/samples/server/petstore/jaxrs-jersey/README.md b/samples/server/petstore/jaxrs-jersey/README.md index 4d4b9499d449..64a6c60dc38e 100644 --- a/samples/server/petstore/jaxrs-jersey/README.md +++ b/samples/server/petstore/jaxrs-jersey/README.md @@ -17,7 +17,7 @@ mvn clean package jetty:run You can then view the OpenAPI v2 specification here: ``` -http://localhost:80/v2/swagger.json +http://localhost:8080/v2/swagger.json ``` Note that if you have configured the `host` to be something other than localhost, the calls through diff --git a/samples/server/petstore/jaxrs-jersey/pom.xml b/samples/server/petstore/jaxrs-jersey/pom.xml index a60e297f03f4..ecfcfd15f7ad 100644 --- a/samples/server/petstore/jaxrs-jersey/pom.xml +++ b/samples/server/petstore/jaxrs-jersey/pom.xml @@ -47,7 +47,7 @@ stopit 10 - 80 + 8080 60000 From 4bb103b98c909c351fb5bde2289860bdbc6115a6 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Mon, 25 May 2020 18:05:16 -0400 Subject: [PATCH 12/16] [scala][finch] Fix remaining vendor extensions format to conventino --- .../codegen/languages/ScalaFinchServerCodegen.java | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaFinchServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaFinchServerCodegen.java index e3e9c4f419eb..6dba7c2de814 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaFinchServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaFinchServerCodegen.java @@ -240,9 +240,9 @@ public Map postProcessOperationsWithModels(Map o // Converts GET /foo/bar => get("foo" :: "bar") generateScalaPath(op); - // Generates e.g. uuid :: header("boo") :: params("baa") under key "x-codegen-pathParams" - // Generates e.g. (id: UUID, headerBoo: String, paramBaa: String) under key "x-codegen-typedInputParams" - // Generates e.g. (id, headerBoo, paramBaa) under key "x-codegen-inputParams" + // Generates e.g. uuid :: header("boo") :: params("baa") under key "x-codegen-path-params" + // Generates e.g. (id: UUID, headerBoo: String, paramBaa: String) under key "x-codegen-typed-input-params" + // Generates e.g. (id, headerBoo, paramBaa) under key "x-codegen-input-params" generateInputParameters(op); //Generate Auth parameters using security: definition @@ -407,9 +407,9 @@ private void generateScalaPath(CodegenOperation op) { private void concatParameters(CodegenOperation op) { - String path = colConcat(colConcat(op.vendorExtensions.get("x-codegen-path").toString(), op.vendorExtensions.get("x-codegen-pathParams").toString()), op.vendorExtensions.get("x-codegen-authParams").toString()); - String parameters = csvConcat(op.vendorExtensions.get("x-codegen-inputParams").toString(), op.vendorExtensions.get("x-codegen-authInputParams").toString()); - String typedParameters = csvConcat(op.vendorExtensions.get("x-codegen-typedInputParams").toString(), op.vendorExtensions.get("x-codegen-typedAuthInputParams").toString()); + String path = colConcat(colConcat(op.vendorExtensions.get("x-codegen-path").toString(), op.vendorExtensions.get("x-codegen-path-params").toString()), op.vendorExtensions.get("x-codegen-auth-params").toString()); + String parameters = csvConcat(op.vendorExtensions.get("x-codegen-input-params").toString(), op.vendorExtensions.get("x-codegen-auth-input-params").toString()); + String typedParameters = csvConcat(op.vendorExtensions.get("x-codegen-typed-input-params").toString(), op.vendorExtensions.get("x-codegen-typed-auth-input-params").toString()); // The input parameters for functions op.vendorExtensions.put("x-codegen-paths", path); From 918ff2dd87bdbd0e1ac15d0ddf74e4e8e10e6c36 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Tue, 26 May 2020 21:40:07 -0400 Subject: [PATCH 13/16] [scala] The -D option was replaced with --global-property --- bin/scala-finch-petstore-server.sh | 2 +- bin/scala-lagom-server-petstore.sh | 2 +- bin/scalaz-petstore.sh | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/scala-finch-petstore-server.sh b/bin/scala-finch-petstore-server.sh index 080d338ae7f3..08fd0ae1e7d5 100755 --- a/bin/scala-finch-petstore-server.sh +++ b/bin/scala-finch-petstore-server.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/scala-finch -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-finch -o samples/server/petstore/scala-finch -DskipFormModel=true $@" +ags="generate -t modules/openapi-generator/src/main/resources/scala-finch -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-finch -o samples/server/petstore/scala-finch --global-property skipFormModel=true $@" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/scala-lagom-server-petstore.sh b/bin/scala-lagom-server-petstore.sh index ab3720b618e8..ff9ab8ce7177 100755 --- a/bin/scala-lagom-server-petstore.sh +++ b/bin/scala-lagom-server-petstore.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/scala-lagom-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-lagom-server -o samples/server/petstore/scala-lagom-server -DskipFormModel=true $@" +ags="generate -t modules/openapi-generator/src/main/resources/scala-lagom-server -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scala-lagom-server -o samples/server/petstore/scala-lagom-server --global-property skipFormModel=true $@" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/scalaz-petstore.sh b/bin/scalaz-petstore.sh index ff35e33a52b3..dca1f9544f5a 100755 --- a/bin/scalaz-petstore.sh +++ b/bin/scalaz-petstore.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/scalaz -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scalaz -o samples/client/petstore/scalaz -DskipFormModel=true $@" +ags="generate -t modules/openapi-generator/src/main/resources/scalaz -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g scalaz -o samples/client/petstore/scalaz --global-property skipFormModel=true $@" java $JAVA_OPTS -jar $executable $ags From afa2c42963991af069f18360f89ed72df85af7c6 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Tue, 26 May 2020 21:50:25 -0400 Subject: [PATCH 14/16] [samples] Regenerate --- .../.openapi-generator/FILES | 36 +++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 samples/client/petstore/kotlin-jvm-okhttp4-coroutines/.openapi-generator/FILES diff --git a/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/.openapi-generator/FILES b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/.openapi-generator/FILES new file mode 100644 index 000000000000..f2b161556c38 --- /dev/null +++ b/samples/client/petstore/kotlin-jvm-okhttp4-coroutines/.openapi-generator/FILES @@ -0,0 +1,36 @@ +.openapi-generator-ignore +README.md +build.gradle +docs/ApiResponse.md +docs/Category.md +docs/Order.md +docs/Pet.md +docs/PetApi.md +docs/StoreApi.md +docs/Tag.md +docs/User.md +docs/UserApi.md +settings.gradle +src/main/kotlin/org/openapitools/client/apis/PetApi.kt +src/main/kotlin/org/openapitools/client/apis/StoreApi.kt +src/main/kotlin/org/openapitools/client/apis/UserApi.kt +src/main/kotlin/org/openapitools/client/infrastructure/ApiAbstractions.kt +src/main/kotlin/org/openapitools/client/infrastructure/ApiClient.kt +src/main/kotlin/org/openapitools/client/infrastructure/ApiInfrastructureResponse.kt +src/main/kotlin/org/openapitools/client/infrastructure/ApplicationDelegates.kt +src/main/kotlin/org/openapitools/client/infrastructure/ByteArrayAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/DateAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/Errors.kt +src/main/kotlin/org/openapitools/client/infrastructure/LocalDateAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/LocalDateTimeAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/OffsetDateTimeAdapter.kt +src/main/kotlin/org/openapitools/client/infrastructure/RequestConfig.kt +src/main/kotlin/org/openapitools/client/infrastructure/RequestMethod.kt +src/main/kotlin/org/openapitools/client/infrastructure/ResponseExtensions.kt +src/main/kotlin/org/openapitools/client/infrastructure/Serializer.kt +src/main/kotlin/org/openapitools/client/models/ApiResponse.kt +src/main/kotlin/org/openapitools/client/models/Category.kt +src/main/kotlin/org/openapitools/client/models/Order.kt +src/main/kotlin/org/openapitools/client/models/Pet.kt +src/main/kotlin/org/openapitools/client/models/Tag.kt +src/main/kotlin/org/openapitools/client/models/User.kt From db5ec21913a9cea1e8ba3da04e6f492d1beea348 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sat, 30 May 2020 15:49:21 -0400 Subject: [PATCH 15/16] Fix -DskipFormModel usage which has been moved to --global-property skipFormModel=true --- bin/apex-petstore.sh | 2 +- bin/ruby-client-petstore-faraday.sh | 2 +- bin/ruby-client-petstore.sh | 2 +- docs/customization.md | 8 +++++++- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/bin/apex-petstore.sh b/bin/apex-petstore.sh index 28863b97d247..bdafe9e58252 100755 --- a/bin/apex-petstore.sh +++ b/bin/apex-petstore.sh @@ -27,6 +27,6 @@ fi # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/apex -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g apex -o samples/client/petstore/apex -DskipFormModel=true $@" +ags="generate -t modules/openapi-generator/src/main/resources/apex -i modules/openapi-generator/src/test/resources/3_0/petstore.yaml -g apex -o samples/client/petstore/apex --global-property skipFormModel=true $@" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/ruby-client-petstore-faraday.sh b/bin/ruby-client-petstore-faraday.sh index 3a8afdd28d11..502cc689fe3c 100755 --- a/bin/ruby-client-petstore-faraday.sh +++ b/bin/ruby-client-petstore-faraday.sh @@ -38,6 +38,6 @@ find samples/client/petstore/ruby-faraday/spec -type f -not -name petstore_helpe # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore-faraday.json -o samples/client/petstore/ruby-faraday --additional-properties skipFormModel=true $@" +ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore-faraday.json -o samples/client/petstore/ruby-faraday --global-property skipFormModel=true $@" java $JAVA_OPTS -jar $executable $ags diff --git a/bin/ruby-client-petstore.sh b/bin/ruby-client-petstore.sh index 292d70a443a0..8a92eb8f1ac0 100755 --- a/bin/ruby-client-petstore.sh +++ b/bin/ruby-client-petstore.sh @@ -38,6 +38,6 @@ find samples/client/petstore/ruby/spec -type f -not -name petstore_helper.rb -no # if you've executed sbt assembly previously it will use that instead. export JAVA_OPTS="${JAVA_OPTS} -Xmx1024M -DloggerPath=conf/log4j.properties" -ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby --additional-properties skipFormModel=true $@" +ags="generate -t modules/openapi-generator/src/main/resources/ruby-client -i modules/openapi-generator/src/test/resources/3_0/petstore-with-fake-endpoints-models-for-testing.yaml -g ruby -c bin/ruby-petstore.json -o samples/client/petstore/ruby --global-property skipFormModel=true $@" java $JAVA_OPTS -jar $executable $ags diff --git a/docs/customization.md b/docs/customization.md index 04058ad92bbf..fe40349f31e1 100644 --- a/docs/customization.md +++ b/docs/customization.md @@ -143,7 +143,13 @@ When using selective generation, _only_ the templates needed for the specific ge To skip models defined as the form parameters in "requestBody", please use `skipFormModel` (default to false) (this option is introduced at v3.2.2) ```sh -java -DskipFormModel=true +java -DskipFormModel=true generate … +``` + +or + +```sh +java generate --global-property skipFormModel=true … ``` This option will be helpful to skip model generation due to the form parameter, which is defined differently in OAS3 as there's no form parameter in OAS3 From d961b12aa605314a52c268fd0cf9612fe33ff9e9 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sat, 30 May 2020 16:33:33 -0400 Subject: [PATCH 16/16] [samples] Regenerate --- .../ruby-faraday/.openapi-generator/FILES | 18 - .../client/petstore/ruby-faraday/README.md | 6 - .../ruby-faraday/docs/InlineObject.md | 19 - .../ruby-faraday/docs/InlineObject1.md | 19 - .../ruby-faraday/docs/InlineObject2.md | 19 - .../ruby-faraday/docs/InlineObject3.md | 43 -- .../ruby-faraday/docs/InlineObject4.md | 19 - .../ruby-faraday/docs/InlineObject5.md | 19 - .../petstore/ruby-faraday/lib/petstore.rb | 6 - .../lib/petstore/models/inline_object.rb | 217 ------- .../lib/petstore/models/inline_object1.rb | 217 ------- .../lib/petstore/models/inline_object2.rb | 255 --------- .../lib/petstore/models/inline_object3.rb | 538 ------------------ .../lib/petstore/models/inline_object4.rb | 227 -------- .../lib/petstore/models/inline_object5.rb | 222 -------- .../spec/models/inline_object1_spec.rb | 47 -- .../spec/models/inline_object2_spec.rb | 55 -- .../spec/models/inline_object3_spec.rb | 119 ---- .../spec/models/inline_object4_spec.rb | 47 -- .../spec/models/inline_object5_spec.rb | 47 -- .../spec/models/inline_object_spec.rb | 47 -- .../petstore/ruby/.openapi-generator/FILES | 18 - samples/client/petstore/ruby/README.md | 6 - .../client/petstore/ruby/docs/InlineObject.md | 19 - .../petstore/ruby/docs/InlineObject1.md | 19 - .../petstore/ruby/docs/InlineObject2.md | 19 - .../petstore/ruby/docs/InlineObject3.md | 43 -- .../petstore/ruby/docs/InlineObject4.md | 19 - .../petstore/ruby/docs/InlineObject5.md | 19 - samples/client/petstore/ruby/lib/petstore.rb | 6 - .../ruby/lib/petstore/models/inline_object.rb | 217 ------- .../lib/petstore/models/inline_object1.rb | 217 ------- .../lib/petstore/models/inline_object2.rb | 255 --------- .../lib/petstore/models/inline_object3.rb | 538 ------------------ .../lib/petstore/models/inline_object4.rb | 227 -------- .../lib/petstore/models/inline_object5.rb | 222 -------- .../ruby/spec/models/inline_object1_spec.rb | 47 -- .../ruby/spec/models/inline_object2_spec.rb | 55 -- .../ruby/spec/models/inline_object3_spec.rb | 119 ---- .../ruby/spec/models/inline_object4_spec.rb | 47 -- .../ruby/spec/models/inline_object5_spec.rb | 47 -- .../ruby/spec/models/inline_object_spec.rb | 47 -- 42 files changed, 4412 deletions(-) delete mode 100644 samples/client/petstore/ruby-faraday/docs/InlineObject.md delete mode 100644 samples/client/petstore/ruby-faraday/docs/InlineObject1.md delete mode 100644 samples/client/petstore/ruby-faraday/docs/InlineObject2.md delete mode 100644 samples/client/petstore/ruby-faraday/docs/InlineObject3.md delete mode 100644 samples/client/petstore/ruby-faraday/docs/InlineObject4.md delete mode 100644 samples/client/petstore/ruby-faraday/docs/InlineObject5.md delete mode 100644 samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object.rb delete mode 100644 samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object1.rb delete mode 100644 samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object2.rb delete mode 100644 samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object3.rb delete mode 100644 samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object4.rb delete mode 100644 samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object5.rb delete mode 100644 samples/client/petstore/ruby-faraday/spec/models/inline_object1_spec.rb delete mode 100644 samples/client/petstore/ruby-faraday/spec/models/inline_object2_spec.rb delete mode 100644 samples/client/petstore/ruby-faraday/spec/models/inline_object3_spec.rb delete mode 100644 samples/client/petstore/ruby-faraday/spec/models/inline_object4_spec.rb delete mode 100644 samples/client/petstore/ruby-faraday/spec/models/inline_object5_spec.rb delete mode 100644 samples/client/petstore/ruby-faraday/spec/models/inline_object_spec.rb delete mode 100644 samples/client/petstore/ruby/docs/InlineObject.md delete mode 100644 samples/client/petstore/ruby/docs/InlineObject1.md delete mode 100644 samples/client/petstore/ruby/docs/InlineObject2.md delete mode 100644 samples/client/petstore/ruby/docs/InlineObject3.md delete mode 100644 samples/client/petstore/ruby/docs/InlineObject4.md delete mode 100644 samples/client/petstore/ruby/docs/InlineObject5.md delete mode 100644 samples/client/petstore/ruby/lib/petstore/models/inline_object.rb delete mode 100644 samples/client/petstore/ruby/lib/petstore/models/inline_object1.rb delete mode 100644 samples/client/petstore/ruby/lib/petstore/models/inline_object2.rb delete mode 100644 samples/client/petstore/ruby/lib/petstore/models/inline_object3.rb delete mode 100644 samples/client/petstore/ruby/lib/petstore/models/inline_object4.rb delete mode 100644 samples/client/petstore/ruby/lib/petstore/models/inline_object5.rb delete mode 100644 samples/client/petstore/ruby/spec/models/inline_object1_spec.rb delete mode 100644 samples/client/petstore/ruby/spec/models/inline_object2_spec.rb delete mode 100644 samples/client/petstore/ruby/spec/models/inline_object3_spec.rb delete mode 100644 samples/client/petstore/ruby/spec/models/inline_object4_spec.rb delete mode 100644 samples/client/petstore/ruby/spec/models/inline_object5_spec.rb delete mode 100644 samples/client/petstore/ruby/spec/models/inline_object_spec.rb diff --git a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES index 61a40c4b9a02..1bb03794c747 100644 --- a/samples/client/petstore/ruby-faraday/.openapi-generator/FILES +++ b/samples/client/petstore/ruby-faraday/.openapi-generator/FILES @@ -32,12 +32,6 @@ docs/Foo.md docs/FormatTest.md docs/HasOnlyReadOnly.md docs/HealthCheckResult.md -docs/InlineObject.md -docs/InlineObject1.md -docs/InlineObject2.md -docs/InlineObject3.md -docs/InlineObject4.md -docs/InlineObject5.md docs/InlineResponseDefault.md docs/List.md docs/MapTest.md @@ -97,12 +91,6 @@ lib/petstore/models/foo.rb lib/petstore/models/format_test.rb lib/petstore/models/has_only_read_only.rb lib/petstore/models/health_check_result.rb -lib/petstore/models/inline_object.rb -lib/petstore/models/inline_object1.rb -lib/petstore/models/inline_object2.rb -lib/petstore/models/inline_object3.rb -lib/petstore/models/inline_object4.rb -lib/petstore/models/inline_object5.rb lib/petstore/models/inline_response_default.rb lib/petstore/models/list.rb lib/petstore/models/map_test.rb @@ -157,12 +145,6 @@ spec/models/foo_spec.rb spec/models/format_test_spec.rb spec/models/has_only_read_only_spec.rb spec/models/health_check_result_spec.rb -spec/models/inline_object1_spec.rb -spec/models/inline_object2_spec.rb -spec/models/inline_object3_spec.rb -spec/models/inline_object4_spec.rb -spec/models/inline_object5_spec.rb -spec/models/inline_object_spec.rb spec/models/inline_response_default_spec.rb spec/models/list_spec.rb spec/models/map_test_spec.rb diff --git a/samples/client/petstore/ruby-faraday/README.md b/samples/client/petstore/ruby-faraday/README.md index 719039e53116..35c76f3817e4 100644 --- a/samples/client/petstore/ruby-faraday/README.md +++ b/samples/client/petstore/ruby-faraday/README.md @@ -141,12 +141,6 @@ Class | Method | HTTP request | Description - [Petstore::FormatTest](docs/FormatTest.md) - [Petstore::HasOnlyReadOnly](docs/HasOnlyReadOnly.md) - [Petstore::HealthCheckResult](docs/HealthCheckResult.md) - - [Petstore::InlineObject](docs/InlineObject.md) - - [Petstore::InlineObject1](docs/InlineObject1.md) - - [Petstore::InlineObject2](docs/InlineObject2.md) - - [Petstore::InlineObject3](docs/InlineObject3.md) - - [Petstore::InlineObject4](docs/InlineObject4.md) - - [Petstore::InlineObject5](docs/InlineObject5.md) - [Petstore::InlineResponseDefault](docs/InlineResponseDefault.md) - [Petstore::List](docs/List.md) - [Petstore::MapTest](docs/MapTest.md) diff --git a/samples/client/petstore/ruby-faraday/docs/InlineObject.md b/samples/client/petstore/ruby-faraday/docs/InlineObject.md deleted file mode 100644 index f5211d44464c..000000000000 --- a/samples/client/petstore/ruby-faraday/docs/InlineObject.md +++ /dev/null @@ -1,19 +0,0 @@ -# Petstore::InlineObject - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **String** | Updated name of the pet | [optional] -**status** | **String** | Updated status of the pet | [optional] - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject.new(name: null, - status: null) -``` - - diff --git a/samples/client/petstore/ruby-faraday/docs/InlineObject1.md b/samples/client/petstore/ruby-faraday/docs/InlineObject1.md deleted file mode 100644 index bac17e753cdc..000000000000 --- a/samples/client/petstore/ruby-faraday/docs/InlineObject1.md +++ /dev/null @@ -1,19 +0,0 @@ -# Petstore::InlineObject1 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**additional_metadata** | **String** | Additional data to pass to server | [optional] -**file** | **File** | file to upload | [optional] - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject1.new(additional_metadata: null, - file: null) -``` - - diff --git a/samples/client/petstore/ruby-faraday/docs/InlineObject2.md b/samples/client/petstore/ruby-faraday/docs/InlineObject2.md deleted file mode 100644 index 31118c5b262e..000000000000 --- a/samples/client/petstore/ruby-faraday/docs/InlineObject2.md +++ /dev/null @@ -1,19 +0,0 @@ -# Petstore::InlineObject2 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**enum_form_string_array** | **Array<String>** | Form parameter enum test (string array) | [optional] -**enum_form_string** | **String** | Form parameter enum test (string) | [optional] [default to '-efg'] - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject2.new(enum_form_string_array: null, - enum_form_string: null) -``` - - diff --git a/samples/client/petstore/ruby-faraday/docs/InlineObject3.md b/samples/client/petstore/ruby-faraday/docs/InlineObject3.md deleted file mode 100644 index b6cb7ccb29b1..000000000000 --- a/samples/client/petstore/ruby-faraday/docs/InlineObject3.md +++ /dev/null @@ -1,43 +0,0 @@ -# Petstore::InlineObject3 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**integer** | **Integer** | None | [optional] -**int32** | **Integer** | None | [optional] -**int64** | **Integer** | None | [optional] -**number** | **Float** | None | -**float** | **Float** | None | [optional] -**double** | **Float** | None | -**string** | **String** | None | [optional] -**pattern_without_delimiter** | **String** | None | -**byte** | **String** | None | -**binary** | **File** | None | [optional] -**date** | **Date** | None | [optional] -**date_time** | **DateTime** | None | [optional] -**password** | **String** | None | [optional] -**callback** | **String** | None | [optional] - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject3.new(integer: null, - int32: null, - int64: null, - number: null, - float: null, - double: null, - string: null, - pattern_without_delimiter: null, - byte: null, - binary: null, - date: null, - date_time: null, - password: null, - callback: null) -``` - - diff --git a/samples/client/petstore/ruby-faraday/docs/InlineObject4.md b/samples/client/petstore/ruby-faraday/docs/InlineObject4.md deleted file mode 100644 index 97179c3e3772..000000000000 --- a/samples/client/petstore/ruby-faraday/docs/InlineObject4.md +++ /dev/null @@ -1,19 +0,0 @@ -# Petstore::InlineObject4 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**param** | **String** | field1 | -**param2** | **String** | field2 | - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject4.new(param: null, - param2: null) -``` - - diff --git a/samples/client/petstore/ruby-faraday/docs/InlineObject5.md b/samples/client/petstore/ruby-faraday/docs/InlineObject5.md deleted file mode 100644 index 23c1df99ffeb..000000000000 --- a/samples/client/petstore/ruby-faraday/docs/InlineObject5.md +++ /dev/null @@ -1,19 +0,0 @@ -# Petstore::InlineObject5 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**additional_metadata** | **String** | Additional data to pass to server | [optional] -**required_file** | **File** | file to upload | - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject5.new(additional_metadata: null, - required_file: null) -``` - - diff --git a/samples/client/petstore/ruby-faraday/lib/petstore.rb b/samples/client/petstore/ruby-faraday/lib/petstore.rb index 7f8ae56e123b..f0df2170db08 100644 --- a/samples/client/petstore/ruby-faraday/lib/petstore.rb +++ b/samples/client/petstore/ruby-faraday/lib/petstore.rb @@ -40,12 +40,6 @@ require 'petstore/models/format_test' require 'petstore/models/has_only_read_only' require 'petstore/models/health_check_result' -require 'petstore/models/inline_object' -require 'petstore/models/inline_object1' -require 'petstore/models/inline_object2' -require 'petstore/models/inline_object3' -require 'petstore/models/inline_object4' -require 'petstore/models/inline_object5' require 'petstore/models/inline_response_default' require 'petstore/models/list' require 'petstore/models/map_test' diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object.rb deleted file mode 100644 index 7d2ce0e05f39..000000000000 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object.rb +++ /dev/null @@ -1,217 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject - # Updated name of the pet - attr_accessor :name - - # Updated status of the pet - attr_accessor :status - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'name' => :'name', - :'status' => :'status' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'name' => :'String', - :'status' => :'String' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'name') - self.name = attributes[:'name'] - end - - if attributes.key?(:'status') - self.status = attributes[:'status'] - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - true - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - name == o.name && - status == o.status - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [name, status].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object1.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object1.rb deleted file mode 100644 index 45a9d5bfcd72..000000000000 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object1.rb +++ /dev/null @@ -1,217 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject1 - # Additional data to pass to server - attr_accessor :additional_metadata - - # file to upload - attr_accessor :file - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'additional_metadata' => :'additionalMetadata', - :'file' => :'file' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'additional_metadata' => :'String', - :'file' => :'File' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject1` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject1`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'additional_metadata') - self.additional_metadata = attributes[:'additional_metadata'] - end - - if attributes.key?(:'file') - self.file = attributes[:'file'] - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - true - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - additional_metadata == o.additional_metadata && - file == o.file - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [additional_metadata, file].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object2.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object2.rb deleted file mode 100644 index 51784af066b6..000000000000 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object2.rb +++ /dev/null @@ -1,255 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject2 - # Form parameter enum test (string array) - attr_accessor :enum_form_string_array - - # Form parameter enum test (string) - attr_accessor :enum_form_string - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'enum_form_string_array' => :'enum_form_string_array', - :'enum_form_string' => :'enum_form_string' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'enum_form_string_array' => :'Array', - :'enum_form_string' => :'String' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject2` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject2`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'enum_form_string_array') - if (value = attributes[:'enum_form_string_array']).is_a?(Array) - self.enum_form_string_array = value - end - end - - if attributes.key?(:'enum_form_string') - self.enum_form_string = attributes[:'enum_form_string'] - else - self.enum_form_string = '-efg' - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - enum_form_string_validator = EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"]) - return false unless enum_form_string_validator.valid?(@enum_form_string) - true - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] enum_form_string Object to be assigned - def enum_form_string=(enum_form_string) - validator = EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"]) - unless validator.valid?(enum_form_string) - fail ArgumentError, "invalid value for \"enum_form_string\", must be one of #{validator.allowable_values}." - end - @enum_form_string = enum_form_string - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - enum_form_string_array == o.enum_form_string_array && - enum_form_string == o.enum_form_string - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [enum_form_string_array, enum_form_string].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object3.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object3.rb deleted file mode 100644 index 71fe8bd38a82..000000000000 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object3.rb +++ /dev/null @@ -1,538 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject3 - # None - attr_accessor :integer - - # None - attr_accessor :int32 - - # None - attr_accessor :int64 - - # None - attr_accessor :number - - # None - attr_accessor :float - - # None - attr_accessor :double - - # None - attr_accessor :string - - # None - attr_accessor :pattern_without_delimiter - - # None - attr_accessor :byte - - # None - attr_accessor :binary - - # None - attr_accessor :date - - # None - attr_accessor :date_time - - # None - attr_accessor :password - - # None - attr_accessor :callback - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'integer' => :'integer', - :'int32' => :'int32', - :'int64' => :'int64', - :'number' => :'number', - :'float' => :'float', - :'double' => :'double', - :'string' => :'string', - :'pattern_without_delimiter' => :'pattern_without_delimiter', - :'byte' => :'byte', - :'binary' => :'binary', - :'date' => :'date', - :'date_time' => :'dateTime', - :'password' => :'password', - :'callback' => :'callback' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'integer' => :'Integer', - :'int32' => :'Integer', - :'int64' => :'Integer', - :'number' => :'Float', - :'float' => :'Float', - :'double' => :'Float', - :'string' => :'String', - :'pattern_without_delimiter' => :'String', - :'byte' => :'String', - :'binary' => :'File', - :'date' => :'Date', - :'date_time' => :'DateTime', - :'password' => :'String', - :'callback' => :'String' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject3` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject3`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'integer') - self.integer = attributes[:'integer'] - end - - if attributes.key?(:'int32') - self.int32 = attributes[:'int32'] - end - - if attributes.key?(:'int64') - self.int64 = attributes[:'int64'] - end - - if attributes.key?(:'number') - self.number = attributes[:'number'] - end - - if attributes.key?(:'float') - self.float = attributes[:'float'] - end - - if attributes.key?(:'double') - self.double = attributes[:'double'] - end - - if attributes.key?(:'string') - self.string = attributes[:'string'] - end - - if attributes.key?(:'pattern_without_delimiter') - self.pattern_without_delimiter = attributes[:'pattern_without_delimiter'] - end - - if attributes.key?(:'byte') - self.byte = attributes[:'byte'] - end - - if attributes.key?(:'binary') - self.binary = attributes[:'binary'] - end - - if attributes.key?(:'date') - self.date = attributes[:'date'] - end - - if attributes.key?(:'date_time') - self.date_time = attributes[:'date_time'] - end - - if attributes.key?(:'password') - self.password = attributes[:'password'] - end - - if attributes.key?(:'callback') - self.callback = attributes[:'callback'] - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - if !@integer.nil? && @integer > 100 - invalid_properties.push('invalid value for "integer", must be smaller than or equal to 100.') - end - - if !@integer.nil? && @integer < 10 - invalid_properties.push('invalid value for "integer", must be greater than or equal to 10.') - end - - if !@int32.nil? && @int32 > 200 - invalid_properties.push('invalid value for "int32", must be smaller than or equal to 200.') - end - - if !@int32.nil? && @int32 < 20 - invalid_properties.push('invalid value for "int32", must be greater than or equal to 20.') - end - - if @number.nil? - invalid_properties.push('invalid value for "number", number cannot be nil.') - end - - if @number > 543.2 - invalid_properties.push('invalid value for "number", must be smaller than or equal to 543.2.') - end - - if @number < 32.1 - invalid_properties.push('invalid value for "number", must be greater than or equal to 32.1.') - end - - if !@float.nil? && @float > 987.6 - invalid_properties.push('invalid value for "float", must be smaller than or equal to 987.6.') - end - - if @double.nil? - invalid_properties.push('invalid value for "double", double cannot be nil.') - end - - if @double > 123.4 - invalid_properties.push('invalid value for "double", must be smaller than or equal to 123.4.') - end - - if @double < 67.8 - invalid_properties.push('invalid value for "double", must be greater than or equal to 67.8.') - end - - pattern = Regexp.new(/[a-z]/i) - if !@string.nil? && @string !~ pattern - invalid_properties.push("invalid value for \"string\", must conform to the pattern #{pattern}.") - end - - if @pattern_without_delimiter.nil? - invalid_properties.push('invalid value for "pattern_without_delimiter", pattern_without_delimiter cannot be nil.') - end - - pattern = Regexp.new(/^[A-Z].*/) - if @pattern_without_delimiter !~ pattern - invalid_properties.push("invalid value for \"pattern_without_delimiter\", must conform to the pattern #{pattern}.") - end - - if @byte.nil? - invalid_properties.push('invalid value for "byte", byte cannot be nil.') - end - - if !@password.nil? && @password.to_s.length > 64 - invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 64.') - end - - if !@password.nil? && @password.to_s.length < 10 - invalid_properties.push('invalid value for "password", the character length must be great than or equal to 10.') - end - - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - return false if !@integer.nil? && @integer > 100 - return false if !@integer.nil? && @integer < 10 - return false if !@int32.nil? && @int32 > 200 - return false if !@int32.nil? && @int32 < 20 - return false if @number.nil? - return false if @number > 543.2 - return false if @number < 32.1 - return false if !@float.nil? && @float > 987.6 - return false if @double.nil? - return false if @double > 123.4 - return false if @double < 67.8 - return false if !@string.nil? && @string !~ Regexp.new(/[a-z]/i) - return false if @pattern_without_delimiter.nil? - return false if @pattern_without_delimiter !~ Regexp.new(/^[A-Z].*/) - return false if @byte.nil? - return false if !@password.nil? && @password.to_s.length > 64 - return false if !@password.nil? && @password.to_s.length < 10 - true - end - - # Custom attribute writer method with validation - # @param [Object] integer Value to be assigned - def integer=(integer) - if !integer.nil? && integer > 100 - fail ArgumentError, 'invalid value for "integer", must be smaller than or equal to 100.' - end - - if !integer.nil? && integer < 10 - fail ArgumentError, 'invalid value for "integer", must be greater than or equal to 10.' - end - - @integer = integer - end - - # Custom attribute writer method with validation - # @param [Object] int32 Value to be assigned - def int32=(int32) - if !int32.nil? && int32 > 200 - fail ArgumentError, 'invalid value for "int32", must be smaller than or equal to 200.' - end - - if !int32.nil? && int32 < 20 - fail ArgumentError, 'invalid value for "int32", must be greater than or equal to 20.' - end - - @int32 = int32 - end - - # Custom attribute writer method with validation - # @param [Object] number Value to be assigned - def number=(number) - if number.nil? - fail ArgumentError, 'number cannot be nil' - end - - if number > 543.2 - fail ArgumentError, 'invalid value for "number", must be smaller than or equal to 543.2.' - end - - if number < 32.1 - fail ArgumentError, 'invalid value for "number", must be greater than or equal to 32.1.' - end - - @number = number - end - - # Custom attribute writer method with validation - # @param [Object] float Value to be assigned - def float=(float) - if !float.nil? && float > 987.6 - fail ArgumentError, 'invalid value for "float", must be smaller than or equal to 987.6.' - end - - @float = float - end - - # Custom attribute writer method with validation - # @param [Object] double Value to be assigned - def double=(double) - if double.nil? - fail ArgumentError, 'double cannot be nil' - end - - if double > 123.4 - fail ArgumentError, 'invalid value for "double", must be smaller than or equal to 123.4.' - end - - if double < 67.8 - fail ArgumentError, 'invalid value for "double", must be greater than or equal to 67.8.' - end - - @double = double - end - - # Custom attribute writer method with validation - # @param [Object] string Value to be assigned - def string=(string) - pattern = Regexp.new(/[a-z]/i) - if !string.nil? && string !~ pattern - fail ArgumentError, "invalid value for \"string\", must conform to the pattern #{pattern}." - end - - @string = string - end - - # Custom attribute writer method with validation - # @param [Object] pattern_without_delimiter Value to be assigned - def pattern_without_delimiter=(pattern_without_delimiter) - if pattern_without_delimiter.nil? - fail ArgumentError, 'pattern_without_delimiter cannot be nil' - end - - pattern = Regexp.new(/^[A-Z].*/) - if pattern_without_delimiter !~ pattern - fail ArgumentError, "invalid value for \"pattern_without_delimiter\", must conform to the pattern #{pattern}." - end - - @pattern_without_delimiter = pattern_without_delimiter - end - - # Custom attribute writer method with validation - # @param [Object] password Value to be assigned - def password=(password) - if !password.nil? && password.to_s.length > 64 - fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 64.' - end - - if !password.nil? && password.to_s.length < 10 - fail ArgumentError, 'invalid value for "password", the character length must be great than or equal to 10.' - end - - @password = password - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - integer == o.integer && - int32 == o.int32 && - int64 == o.int64 && - number == o.number && - float == o.float && - double == o.double && - string == o.string && - pattern_without_delimiter == o.pattern_without_delimiter && - byte == o.byte && - binary == o.binary && - date == o.date && - date_time == o.date_time && - password == o.password && - callback == o.callback - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [integer, int32, int64, number, float, double, string, pattern_without_delimiter, byte, binary, date, date_time, password, callback].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object4.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object4.rb deleted file mode 100644 index 560e747ce79c..000000000000 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object4.rb +++ /dev/null @@ -1,227 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject4 - # field1 - attr_accessor :param - - # field2 - attr_accessor :param2 - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'param' => :'param', - :'param2' => :'param2' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'param' => :'String', - :'param2' => :'String' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject4` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject4`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'param') - self.param = attributes[:'param'] - end - - if attributes.key?(:'param2') - self.param2 = attributes[:'param2'] - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - if @param.nil? - invalid_properties.push('invalid value for "param", param cannot be nil.') - end - - if @param2.nil? - invalid_properties.push('invalid value for "param2", param2 cannot be nil.') - end - - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - return false if @param.nil? - return false if @param2.nil? - true - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - param == o.param && - param2 == o.param2 - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [param, param2].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object5.rb b/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object5.rb deleted file mode 100644 index e75bb452989a..000000000000 --- a/samples/client/petstore/ruby-faraday/lib/petstore/models/inline_object5.rb +++ /dev/null @@ -1,222 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject5 - # Additional data to pass to server - attr_accessor :additional_metadata - - # file to upload - attr_accessor :required_file - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'additional_metadata' => :'additionalMetadata', - :'required_file' => :'requiredFile' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'additional_metadata' => :'String', - :'required_file' => :'File' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject5` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject5`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'additional_metadata') - self.additional_metadata = attributes[:'additional_metadata'] - end - - if attributes.key?(:'required_file') - self.required_file = attributes[:'required_file'] - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - if @required_file.nil? - invalid_properties.push('invalid value for "required_file", required_file cannot be nil.') - end - - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - return false if @required_file.nil? - true - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - additional_metadata == o.additional_metadata && - required_file == o.required_file - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [additional_metadata, required_file].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby-faraday/spec/models/inline_object1_spec.rb b/samples/client/petstore/ruby-faraday/spec/models/inline_object1_spec.rb deleted file mode 100644 index a702fd774eac..000000000000 --- a/samples/client/petstore/ruby-faraday/spec/models/inline_object1_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject1 -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject1' do - before do - # run before each test - @instance = Petstore::InlineObject1.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject1' do - it 'should create an instance of InlineObject1' do - expect(@instance).to be_instance_of(Petstore::InlineObject1) - end - end - describe 'test attribute "additional_metadata"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "file"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end diff --git a/samples/client/petstore/ruby-faraday/spec/models/inline_object2_spec.rb b/samples/client/petstore/ruby-faraday/spec/models/inline_object2_spec.rb deleted file mode 100644 index 7013915ea39d..000000000000 --- a/samples/client/petstore/ruby-faraday/spec/models/inline_object2_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject2 -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject2' do - before do - # run before each test - @instance = Petstore::InlineObject2.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject2' do - it 'should create an instance of InlineObject2' do - expect(@instance).to be_instance_of(Petstore::InlineObject2) - end - end - describe 'test attribute "enum_form_string_array"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - # validator = Petstore::EnumTest::EnumAttributeValidator.new('Array', [">", "$"]) - # validator.allowable_values.each do |value| - # expect { @instance.enum_form_string_array = value }.not_to raise_error - # end - end - end - - describe 'test attribute "enum_form_string"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"]) - # validator.allowable_values.each do |value| - # expect { @instance.enum_form_string = value }.not_to raise_error - # end - end - end - -end diff --git a/samples/client/petstore/ruby-faraday/spec/models/inline_object3_spec.rb b/samples/client/petstore/ruby-faraday/spec/models/inline_object3_spec.rb deleted file mode 100644 index 4daf41b4ace0..000000000000 --- a/samples/client/petstore/ruby-faraday/spec/models/inline_object3_spec.rb +++ /dev/null @@ -1,119 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject3 -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject3' do - before do - # run before each test - @instance = Petstore::InlineObject3.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject3' do - it 'should create an instance of InlineObject3' do - expect(@instance).to be_instance_of(Petstore::InlineObject3) - end - end - describe 'test attribute "integer"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "int32"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "int64"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "number"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "float"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "double"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "string"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "pattern_without_delimiter"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "byte"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "binary"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "date"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "date_time"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "password"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "callback"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end diff --git a/samples/client/petstore/ruby-faraday/spec/models/inline_object4_spec.rb b/samples/client/petstore/ruby-faraday/spec/models/inline_object4_spec.rb deleted file mode 100644 index fa806f95860c..000000000000 --- a/samples/client/petstore/ruby-faraday/spec/models/inline_object4_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject4 -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject4' do - before do - # run before each test - @instance = Petstore::InlineObject4.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject4' do - it 'should create an instance of InlineObject4' do - expect(@instance).to be_instance_of(Petstore::InlineObject4) - end - end - describe 'test attribute "param"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "param2"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end diff --git a/samples/client/petstore/ruby-faraday/spec/models/inline_object5_spec.rb b/samples/client/petstore/ruby-faraday/spec/models/inline_object5_spec.rb deleted file mode 100644 index e2410b21bc09..000000000000 --- a/samples/client/petstore/ruby-faraday/spec/models/inline_object5_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject5 -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject5' do - before do - # run before each test - @instance = Petstore::InlineObject5.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject5' do - it 'should create an instance of InlineObject5' do - expect(@instance).to be_instance_of(Petstore::InlineObject5) - end - end - describe 'test attribute "additional_metadata"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "required_file"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end diff --git a/samples/client/petstore/ruby-faraday/spec/models/inline_object_spec.rb b/samples/client/petstore/ruby-faraday/spec/models/inline_object_spec.rb deleted file mode 100644 index c5a7db44780e..000000000000 --- a/samples/client/petstore/ruby-faraday/spec/models/inline_object_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject' do - before do - # run before each test - @instance = Petstore::InlineObject.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject' do - it 'should create an instance of InlineObject' do - expect(@instance).to be_instance_of(Petstore::InlineObject) - end - end - describe 'test attribute "name"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "status"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end diff --git a/samples/client/petstore/ruby/.openapi-generator/FILES b/samples/client/petstore/ruby/.openapi-generator/FILES index 61a40c4b9a02..1bb03794c747 100644 --- a/samples/client/petstore/ruby/.openapi-generator/FILES +++ b/samples/client/petstore/ruby/.openapi-generator/FILES @@ -32,12 +32,6 @@ docs/Foo.md docs/FormatTest.md docs/HasOnlyReadOnly.md docs/HealthCheckResult.md -docs/InlineObject.md -docs/InlineObject1.md -docs/InlineObject2.md -docs/InlineObject3.md -docs/InlineObject4.md -docs/InlineObject5.md docs/InlineResponseDefault.md docs/List.md docs/MapTest.md @@ -97,12 +91,6 @@ lib/petstore/models/foo.rb lib/petstore/models/format_test.rb lib/petstore/models/has_only_read_only.rb lib/petstore/models/health_check_result.rb -lib/petstore/models/inline_object.rb -lib/petstore/models/inline_object1.rb -lib/petstore/models/inline_object2.rb -lib/petstore/models/inline_object3.rb -lib/petstore/models/inline_object4.rb -lib/petstore/models/inline_object5.rb lib/petstore/models/inline_response_default.rb lib/petstore/models/list.rb lib/petstore/models/map_test.rb @@ -157,12 +145,6 @@ spec/models/foo_spec.rb spec/models/format_test_spec.rb spec/models/has_only_read_only_spec.rb spec/models/health_check_result_spec.rb -spec/models/inline_object1_spec.rb -spec/models/inline_object2_spec.rb -spec/models/inline_object3_spec.rb -spec/models/inline_object4_spec.rb -spec/models/inline_object5_spec.rb -spec/models/inline_object_spec.rb spec/models/inline_response_default_spec.rb spec/models/list_spec.rb spec/models/map_test_spec.rb diff --git a/samples/client/petstore/ruby/README.md b/samples/client/petstore/ruby/README.md index 719039e53116..35c76f3817e4 100644 --- a/samples/client/petstore/ruby/README.md +++ b/samples/client/petstore/ruby/README.md @@ -141,12 +141,6 @@ Class | Method | HTTP request | Description - [Petstore::FormatTest](docs/FormatTest.md) - [Petstore::HasOnlyReadOnly](docs/HasOnlyReadOnly.md) - [Petstore::HealthCheckResult](docs/HealthCheckResult.md) - - [Petstore::InlineObject](docs/InlineObject.md) - - [Petstore::InlineObject1](docs/InlineObject1.md) - - [Petstore::InlineObject2](docs/InlineObject2.md) - - [Petstore::InlineObject3](docs/InlineObject3.md) - - [Petstore::InlineObject4](docs/InlineObject4.md) - - [Petstore::InlineObject5](docs/InlineObject5.md) - [Petstore::InlineResponseDefault](docs/InlineResponseDefault.md) - [Petstore::List](docs/List.md) - [Petstore::MapTest](docs/MapTest.md) diff --git a/samples/client/petstore/ruby/docs/InlineObject.md b/samples/client/petstore/ruby/docs/InlineObject.md deleted file mode 100644 index f5211d44464c..000000000000 --- a/samples/client/petstore/ruby/docs/InlineObject.md +++ /dev/null @@ -1,19 +0,0 @@ -# Petstore::InlineObject - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**name** | **String** | Updated name of the pet | [optional] -**status** | **String** | Updated status of the pet | [optional] - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject.new(name: null, - status: null) -``` - - diff --git a/samples/client/petstore/ruby/docs/InlineObject1.md b/samples/client/petstore/ruby/docs/InlineObject1.md deleted file mode 100644 index bac17e753cdc..000000000000 --- a/samples/client/petstore/ruby/docs/InlineObject1.md +++ /dev/null @@ -1,19 +0,0 @@ -# Petstore::InlineObject1 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**additional_metadata** | **String** | Additional data to pass to server | [optional] -**file** | **File** | file to upload | [optional] - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject1.new(additional_metadata: null, - file: null) -``` - - diff --git a/samples/client/petstore/ruby/docs/InlineObject2.md b/samples/client/petstore/ruby/docs/InlineObject2.md deleted file mode 100644 index 31118c5b262e..000000000000 --- a/samples/client/petstore/ruby/docs/InlineObject2.md +++ /dev/null @@ -1,19 +0,0 @@ -# Petstore::InlineObject2 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**enum_form_string_array** | **Array<String>** | Form parameter enum test (string array) | [optional] -**enum_form_string** | **String** | Form parameter enum test (string) | [optional] [default to '-efg'] - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject2.new(enum_form_string_array: null, - enum_form_string: null) -``` - - diff --git a/samples/client/petstore/ruby/docs/InlineObject3.md b/samples/client/petstore/ruby/docs/InlineObject3.md deleted file mode 100644 index b6cb7ccb29b1..000000000000 --- a/samples/client/petstore/ruby/docs/InlineObject3.md +++ /dev/null @@ -1,43 +0,0 @@ -# Petstore::InlineObject3 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**integer** | **Integer** | None | [optional] -**int32** | **Integer** | None | [optional] -**int64** | **Integer** | None | [optional] -**number** | **Float** | None | -**float** | **Float** | None | [optional] -**double** | **Float** | None | -**string** | **String** | None | [optional] -**pattern_without_delimiter** | **String** | None | -**byte** | **String** | None | -**binary** | **File** | None | [optional] -**date** | **Date** | None | [optional] -**date_time** | **DateTime** | None | [optional] -**password** | **String** | None | [optional] -**callback** | **String** | None | [optional] - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject3.new(integer: null, - int32: null, - int64: null, - number: null, - float: null, - double: null, - string: null, - pattern_without_delimiter: null, - byte: null, - binary: null, - date: null, - date_time: null, - password: null, - callback: null) -``` - - diff --git a/samples/client/petstore/ruby/docs/InlineObject4.md b/samples/client/petstore/ruby/docs/InlineObject4.md deleted file mode 100644 index 97179c3e3772..000000000000 --- a/samples/client/petstore/ruby/docs/InlineObject4.md +++ /dev/null @@ -1,19 +0,0 @@ -# Petstore::InlineObject4 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**param** | **String** | field1 | -**param2** | **String** | field2 | - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject4.new(param: null, - param2: null) -``` - - diff --git a/samples/client/petstore/ruby/docs/InlineObject5.md b/samples/client/petstore/ruby/docs/InlineObject5.md deleted file mode 100644 index 23c1df99ffeb..000000000000 --- a/samples/client/petstore/ruby/docs/InlineObject5.md +++ /dev/null @@ -1,19 +0,0 @@ -# Petstore::InlineObject5 - -## Properties - -Name | Type | Description | Notes ------------- | ------------- | ------------- | ------------- -**additional_metadata** | **String** | Additional data to pass to server | [optional] -**required_file** | **File** | file to upload | - -## Code Sample - -```ruby -require 'Petstore' - -instance = Petstore::InlineObject5.new(additional_metadata: null, - required_file: null) -``` - - diff --git a/samples/client/petstore/ruby/lib/petstore.rb b/samples/client/petstore/ruby/lib/petstore.rb index 7f8ae56e123b..f0df2170db08 100644 --- a/samples/client/petstore/ruby/lib/petstore.rb +++ b/samples/client/petstore/ruby/lib/petstore.rb @@ -40,12 +40,6 @@ require 'petstore/models/format_test' require 'petstore/models/has_only_read_only' require 'petstore/models/health_check_result' -require 'petstore/models/inline_object' -require 'petstore/models/inline_object1' -require 'petstore/models/inline_object2' -require 'petstore/models/inline_object3' -require 'petstore/models/inline_object4' -require 'petstore/models/inline_object5' require 'petstore/models/inline_response_default' require 'petstore/models/list' require 'petstore/models/map_test' diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_object.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_object.rb deleted file mode 100644 index 7d2ce0e05f39..000000000000 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_object.rb +++ /dev/null @@ -1,217 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject - # Updated name of the pet - attr_accessor :name - - # Updated status of the pet - attr_accessor :status - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'name' => :'name', - :'status' => :'status' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'name' => :'String', - :'status' => :'String' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'name') - self.name = attributes[:'name'] - end - - if attributes.key?(:'status') - self.status = attributes[:'status'] - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - true - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - name == o.name && - status == o.status - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [name, status].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_object1.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_object1.rb deleted file mode 100644 index 45a9d5bfcd72..000000000000 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_object1.rb +++ /dev/null @@ -1,217 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject1 - # Additional data to pass to server - attr_accessor :additional_metadata - - # file to upload - attr_accessor :file - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'additional_metadata' => :'additionalMetadata', - :'file' => :'file' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'additional_metadata' => :'String', - :'file' => :'File' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject1` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject1`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'additional_metadata') - self.additional_metadata = attributes[:'additional_metadata'] - end - - if attributes.key?(:'file') - self.file = attributes[:'file'] - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - true - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - additional_metadata == o.additional_metadata && - file == o.file - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [additional_metadata, file].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_object2.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_object2.rb deleted file mode 100644 index 51784af066b6..000000000000 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_object2.rb +++ /dev/null @@ -1,255 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject2 - # Form parameter enum test (string array) - attr_accessor :enum_form_string_array - - # Form parameter enum test (string) - attr_accessor :enum_form_string - - class EnumAttributeValidator - attr_reader :datatype - attr_reader :allowable_values - - def initialize(datatype, allowable_values) - @allowable_values = allowable_values.map do |value| - case datatype.to_s - when /Integer/i - value.to_i - when /Float/i - value.to_f - else - value - end - end - end - - def valid?(value) - !value || allowable_values.include?(value) - end - end - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'enum_form_string_array' => :'enum_form_string_array', - :'enum_form_string' => :'enum_form_string' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'enum_form_string_array' => :'Array', - :'enum_form_string' => :'String' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject2` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject2`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'enum_form_string_array') - if (value = attributes[:'enum_form_string_array']).is_a?(Array) - self.enum_form_string_array = value - end - end - - if attributes.key?(:'enum_form_string') - self.enum_form_string = attributes[:'enum_form_string'] - else - self.enum_form_string = '-efg' - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - enum_form_string_validator = EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"]) - return false unless enum_form_string_validator.valid?(@enum_form_string) - true - end - - # Custom attribute writer method checking allowed values (enum). - # @param [Object] enum_form_string Object to be assigned - def enum_form_string=(enum_form_string) - validator = EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"]) - unless validator.valid?(enum_form_string) - fail ArgumentError, "invalid value for \"enum_form_string\", must be one of #{validator.allowable_values}." - end - @enum_form_string = enum_form_string - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - enum_form_string_array == o.enum_form_string_array && - enum_form_string == o.enum_form_string - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [enum_form_string_array, enum_form_string].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_object3.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_object3.rb deleted file mode 100644 index 71fe8bd38a82..000000000000 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_object3.rb +++ /dev/null @@ -1,538 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject3 - # None - attr_accessor :integer - - # None - attr_accessor :int32 - - # None - attr_accessor :int64 - - # None - attr_accessor :number - - # None - attr_accessor :float - - # None - attr_accessor :double - - # None - attr_accessor :string - - # None - attr_accessor :pattern_without_delimiter - - # None - attr_accessor :byte - - # None - attr_accessor :binary - - # None - attr_accessor :date - - # None - attr_accessor :date_time - - # None - attr_accessor :password - - # None - attr_accessor :callback - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'integer' => :'integer', - :'int32' => :'int32', - :'int64' => :'int64', - :'number' => :'number', - :'float' => :'float', - :'double' => :'double', - :'string' => :'string', - :'pattern_without_delimiter' => :'pattern_without_delimiter', - :'byte' => :'byte', - :'binary' => :'binary', - :'date' => :'date', - :'date_time' => :'dateTime', - :'password' => :'password', - :'callback' => :'callback' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'integer' => :'Integer', - :'int32' => :'Integer', - :'int64' => :'Integer', - :'number' => :'Float', - :'float' => :'Float', - :'double' => :'Float', - :'string' => :'String', - :'pattern_without_delimiter' => :'String', - :'byte' => :'String', - :'binary' => :'File', - :'date' => :'Date', - :'date_time' => :'DateTime', - :'password' => :'String', - :'callback' => :'String' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject3` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject3`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'integer') - self.integer = attributes[:'integer'] - end - - if attributes.key?(:'int32') - self.int32 = attributes[:'int32'] - end - - if attributes.key?(:'int64') - self.int64 = attributes[:'int64'] - end - - if attributes.key?(:'number') - self.number = attributes[:'number'] - end - - if attributes.key?(:'float') - self.float = attributes[:'float'] - end - - if attributes.key?(:'double') - self.double = attributes[:'double'] - end - - if attributes.key?(:'string') - self.string = attributes[:'string'] - end - - if attributes.key?(:'pattern_without_delimiter') - self.pattern_without_delimiter = attributes[:'pattern_without_delimiter'] - end - - if attributes.key?(:'byte') - self.byte = attributes[:'byte'] - end - - if attributes.key?(:'binary') - self.binary = attributes[:'binary'] - end - - if attributes.key?(:'date') - self.date = attributes[:'date'] - end - - if attributes.key?(:'date_time') - self.date_time = attributes[:'date_time'] - end - - if attributes.key?(:'password') - self.password = attributes[:'password'] - end - - if attributes.key?(:'callback') - self.callback = attributes[:'callback'] - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - if !@integer.nil? && @integer > 100 - invalid_properties.push('invalid value for "integer", must be smaller than or equal to 100.') - end - - if !@integer.nil? && @integer < 10 - invalid_properties.push('invalid value for "integer", must be greater than or equal to 10.') - end - - if !@int32.nil? && @int32 > 200 - invalid_properties.push('invalid value for "int32", must be smaller than or equal to 200.') - end - - if !@int32.nil? && @int32 < 20 - invalid_properties.push('invalid value for "int32", must be greater than or equal to 20.') - end - - if @number.nil? - invalid_properties.push('invalid value for "number", number cannot be nil.') - end - - if @number > 543.2 - invalid_properties.push('invalid value for "number", must be smaller than or equal to 543.2.') - end - - if @number < 32.1 - invalid_properties.push('invalid value for "number", must be greater than or equal to 32.1.') - end - - if !@float.nil? && @float > 987.6 - invalid_properties.push('invalid value for "float", must be smaller than or equal to 987.6.') - end - - if @double.nil? - invalid_properties.push('invalid value for "double", double cannot be nil.') - end - - if @double > 123.4 - invalid_properties.push('invalid value for "double", must be smaller than or equal to 123.4.') - end - - if @double < 67.8 - invalid_properties.push('invalid value for "double", must be greater than or equal to 67.8.') - end - - pattern = Regexp.new(/[a-z]/i) - if !@string.nil? && @string !~ pattern - invalid_properties.push("invalid value for \"string\", must conform to the pattern #{pattern}.") - end - - if @pattern_without_delimiter.nil? - invalid_properties.push('invalid value for "pattern_without_delimiter", pattern_without_delimiter cannot be nil.') - end - - pattern = Regexp.new(/^[A-Z].*/) - if @pattern_without_delimiter !~ pattern - invalid_properties.push("invalid value for \"pattern_without_delimiter\", must conform to the pattern #{pattern}.") - end - - if @byte.nil? - invalid_properties.push('invalid value for "byte", byte cannot be nil.') - end - - if !@password.nil? && @password.to_s.length > 64 - invalid_properties.push('invalid value for "password", the character length must be smaller than or equal to 64.') - end - - if !@password.nil? && @password.to_s.length < 10 - invalid_properties.push('invalid value for "password", the character length must be great than or equal to 10.') - end - - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - return false if !@integer.nil? && @integer > 100 - return false if !@integer.nil? && @integer < 10 - return false if !@int32.nil? && @int32 > 200 - return false if !@int32.nil? && @int32 < 20 - return false if @number.nil? - return false if @number > 543.2 - return false if @number < 32.1 - return false if !@float.nil? && @float > 987.6 - return false if @double.nil? - return false if @double > 123.4 - return false if @double < 67.8 - return false if !@string.nil? && @string !~ Regexp.new(/[a-z]/i) - return false if @pattern_without_delimiter.nil? - return false if @pattern_without_delimiter !~ Regexp.new(/^[A-Z].*/) - return false if @byte.nil? - return false if !@password.nil? && @password.to_s.length > 64 - return false if !@password.nil? && @password.to_s.length < 10 - true - end - - # Custom attribute writer method with validation - # @param [Object] integer Value to be assigned - def integer=(integer) - if !integer.nil? && integer > 100 - fail ArgumentError, 'invalid value for "integer", must be smaller than or equal to 100.' - end - - if !integer.nil? && integer < 10 - fail ArgumentError, 'invalid value for "integer", must be greater than or equal to 10.' - end - - @integer = integer - end - - # Custom attribute writer method with validation - # @param [Object] int32 Value to be assigned - def int32=(int32) - if !int32.nil? && int32 > 200 - fail ArgumentError, 'invalid value for "int32", must be smaller than or equal to 200.' - end - - if !int32.nil? && int32 < 20 - fail ArgumentError, 'invalid value for "int32", must be greater than or equal to 20.' - end - - @int32 = int32 - end - - # Custom attribute writer method with validation - # @param [Object] number Value to be assigned - def number=(number) - if number.nil? - fail ArgumentError, 'number cannot be nil' - end - - if number > 543.2 - fail ArgumentError, 'invalid value for "number", must be smaller than or equal to 543.2.' - end - - if number < 32.1 - fail ArgumentError, 'invalid value for "number", must be greater than or equal to 32.1.' - end - - @number = number - end - - # Custom attribute writer method with validation - # @param [Object] float Value to be assigned - def float=(float) - if !float.nil? && float > 987.6 - fail ArgumentError, 'invalid value for "float", must be smaller than or equal to 987.6.' - end - - @float = float - end - - # Custom attribute writer method with validation - # @param [Object] double Value to be assigned - def double=(double) - if double.nil? - fail ArgumentError, 'double cannot be nil' - end - - if double > 123.4 - fail ArgumentError, 'invalid value for "double", must be smaller than or equal to 123.4.' - end - - if double < 67.8 - fail ArgumentError, 'invalid value for "double", must be greater than or equal to 67.8.' - end - - @double = double - end - - # Custom attribute writer method with validation - # @param [Object] string Value to be assigned - def string=(string) - pattern = Regexp.new(/[a-z]/i) - if !string.nil? && string !~ pattern - fail ArgumentError, "invalid value for \"string\", must conform to the pattern #{pattern}." - end - - @string = string - end - - # Custom attribute writer method with validation - # @param [Object] pattern_without_delimiter Value to be assigned - def pattern_without_delimiter=(pattern_without_delimiter) - if pattern_without_delimiter.nil? - fail ArgumentError, 'pattern_without_delimiter cannot be nil' - end - - pattern = Regexp.new(/^[A-Z].*/) - if pattern_without_delimiter !~ pattern - fail ArgumentError, "invalid value for \"pattern_without_delimiter\", must conform to the pattern #{pattern}." - end - - @pattern_without_delimiter = pattern_without_delimiter - end - - # Custom attribute writer method with validation - # @param [Object] password Value to be assigned - def password=(password) - if !password.nil? && password.to_s.length > 64 - fail ArgumentError, 'invalid value for "password", the character length must be smaller than or equal to 64.' - end - - if !password.nil? && password.to_s.length < 10 - fail ArgumentError, 'invalid value for "password", the character length must be great than or equal to 10.' - end - - @password = password - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - integer == o.integer && - int32 == o.int32 && - int64 == o.int64 && - number == o.number && - float == o.float && - double == o.double && - string == o.string && - pattern_without_delimiter == o.pattern_without_delimiter && - byte == o.byte && - binary == o.binary && - date == o.date && - date_time == o.date_time && - password == o.password && - callback == o.callback - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [integer, int32, int64, number, float, double, string, pattern_without_delimiter, byte, binary, date, date_time, password, callback].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_object4.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_object4.rb deleted file mode 100644 index 560e747ce79c..000000000000 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_object4.rb +++ /dev/null @@ -1,227 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject4 - # field1 - attr_accessor :param - - # field2 - attr_accessor :param2 - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'param' => :'param', - :'param2' => :'param2' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'param' => :'String', - :'param2' => :'String' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject4` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject4`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'param') - self.param = attributes[:'param'] - end - - if attributes.key?(:'param2') - self.param2 = attributes[:'param2'] - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - if @param.nil? - invalid_properties.push('invalid value for "param", param cannot be nil.') - end - - if @param2.nil? - invalid_properties.push('invalid value for "param2", param2 cannot be nil.') - end - - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - return false if @param.nil? - return false if @param2.nil? - true - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - param == o.param && - param2 == o.param2 - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [param, param2].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby/lib/petstore/models/inline_object5.rb b/samples/client/petstore/ruby/lib/petstore/models/inline_object5.rb deleted file mode 100644 index e75bb452989a..000000000000 --- a/samples/client/petstore/ruby/lib/petstore/models/inline_object5.rb +++ /dev/null @@ -1,222 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'date' - -module Petstore - class InlineObject5 - # Additional data to pass to server - attr_accessor :additional_metadata - - # file to upload - attr_accessor :required_file - - # Attribute mapping from ruby-style variable name to JSON key. - def self.attribute_map - { - :'additional_metadata' => :'additionalMetadata', - :'required_file' => :'requiredFile' - } - end - - # Attribute type mapping. - def self.openapi_types - { - :'additional_metadata' => :'String', - :'required_file' => :'File' - } - end - - # List of attributes with nullable: true - def self.openapi_nullable - Set.new([ - ]) - end - - # Initializes the object - # @param [Hash] attributes Model attributes in the form of hash - def initialize(attributes = {}) - if (!attributes.is_a?(Hash)) - fail ArgumentError, "The input argument (attributes) must be a hash in `Petstore::InlineObject5` initialize method" - end - - # check to see if the attribute exists and convert string to symbol for hash key - attributes = attributes.each_with_object({}) { |(k, v), h| - if (!self.class.attribute_map.key?(k.to_sym)) - fail ArgumentError, "`#{k}` is not a valid attribute in `Petstore::InlineObject5`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect - end - h[k.to_sym] = v - } - - if attributes.key?(:'additional_metadata') - self.additional_metadata = attributes[:'additional_metadata'] - end - - if attributes.key?(:'required_file') - self.required_file = attributes[:'required_file'] - end - end - - # Show invalid properties with the reasons. Usually used together with valid? - # @return Array for valid properties with the reasons - def list_invalid_properties - invalid_properties = Array.new - if @required_file.nil? - invalid_properties.push('invalid value for "required_file", required_file cannot be nil.') - end - - invalid_properties - end - - # Check to see if the all the properties in the model are valid - # @return true if the model is valid - def valid? - return false if @required_file.nil? - true - end - - # Checks equality by comparing each attribute. - # @param [Object] Object to be compared - def ==(o) - return true if self.equal?(o) - self.class == o.class && - additional_metadata == o.additional_metadata && - required_file == o.required_file - end - - # @see the `==` method - # @param [Object] Object to be compared - def eql?(o) - self == o - end - - # Calculates hash code according to all attributes. - # @return [Integer] Hash code - def hash - [additional_metadata, required_file].hash - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def self.build_from_hash(attributes) - new.build_from_hash(attributes) - end - - # Builds the object from hash - # @param [Hash] attributes Model attributes in the form of hash - # @return [Object] Returns the model itself - def build_from_hash(attributes) - return nil unless attributes.is_a?(Hash) - self.class.openapi_types.each_pair do |key, type| - if type =~ /\AArray<(.*)>/i - # check to ensure the input is an array given that the attribute - # is documented as an array but the input is not - if attributes[self.class.attribute_map[key]].is_a?(Array) - self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) - end - elsif !attributes[self.class.attribute_map[key]].nil? - self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) - end # or else data not found in attributes(hash), not an issue as the data can be optional - end - - self - end - - # Deserializes the data based on type - # @param string type Data type - # @param string value Value to be deserialized - # @return [Object] Deserialized data - def _deserialize(type, value) - case type.to_sym - when :DateTime - DateTime.parse(value) - when :Date - Date.parse(value) - when :String - value.to_s - when :Integer - value.to_i - when :Float - value.to_f - when :Boolean - if value.to_s =~ /\A(true|t|yes|y|1)\z/i - true - else - false - end - when :Object - # generic object (usually a Hash), return directly - value - when /\AArray<(?.+)>\z/ - inner_type = Regexp.last_match[:inner_type] - value.map { |v| _deserialize(inner_type, v) } - when /\AHash<(?.+?), (?.+)>\z/ - k_type = Regexp.last_match[:k_type] - v_type = Regexp.last_match[:v_type] - {}.tap do |hash| - value.each do |k, v| - hash[_deserialize(k_type, k)] = _deserialize(v_type, v) - end - end - else # model - Petstore.const_get(type).build_from_hash(value) - end - end - - # Returns the string representation of the object - # @return [String] String presentation of the object - def to_s - to_hash.to_s - end - - # to_body is an alias to to_hash (backward compatibility) - # @return [Hash] Returns the object in the form of hash - def to_body - to_hash - end - - # Returns the object in the form of hash - # @return [Hash] Returns the object in the form of hash - def to_hash - hash = {} - self.class.attribute_map.each_pair do |attr, param| - value = self.send(attr) - if value.nil? - is_nullable = self.class.openapi_nullable.include?(attr) - next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) - end - - hash[param] = _to_hash(value) - end - hash - end - - # Outputs non-array value in the form of hash - # For object, use to_hash. Otherwise, just return the value - # @param [Object] value Any valid value - # @return [Hash] Returns the value in the form of hash - def _to_hash(value) - if value.is_a?(Array) - value.compact.map { |v| _to_hash(v) } - elsif value.is_a?(Hash) - {}.tap do |hash| - value.each { |k, v| hash[k] = _to_hash(v) } - end - elsif value.respond_to? :to_hash - value.to_hash - else - value - end - end - end -end diff --git a/samples/client/petstore/ruby/spec/models/inline_object1_spec.rb b/samples/client/petstore/ruby/spec/models/inline_object1_spec.rb deleted file mode 100644 index a702fd774eac..000000000000 --- a/samples/client/petstore/ruby/spec/models/inline_object1_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject1 -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject1' do - before do - # run before each test - @instance = Petstore::InlineObject1.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject1' do - it 'should create an instance of InlineObject1' do - expect(@instance).to be_instance_of(Petstore::InlineObject1) - end - end - describe 'test attribute "additional_metadata"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "file"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end diff --git a/samples/client/petstore/ruby/spec/models/inline_object2_spec.rb b/samples/client/petstore/ruby/spec/models/inline_object2_spec.rb deleted file mode 100644 index 7013915ea39d..000000000000 --- a/samples/client/petstore/ruby/spec/models/inline_object2_spec.rb +++ /dev/null @@ -1,55 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject2 -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject2' do - before do - # run before each test - @instance = Petstore::InlineObject2.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject2' do - it 'should create an instance of InlineObject2' do - expect(@instance).to be_instance_of(Petstore::InlineObject2) - end - end - describe 'test attribute "enum_form_string_array"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - # validator = Petstore::EnumTest::EnumAttributeValidator.new('Array', [">", "$"]) - # validator.allowable_values.each do |value| - # expect { @instance.enum_form_string_array = value }.not_to raise_error - # end - end - end - - describe 'test attribute "enum_form_string"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - # validator = Petstore::EnumTest::EnumAttributeValidator.new('String', ["_abc", "-efg", "(xyz)"]) - # validator.allowable_values.each do |value| - # expect { @instance.enum_form_string = value }.not_to raise_error - # end - end - end - -end diff --git a/samples/client/petstore/ruby/spec/models/inline_object3_spec.rb b/samples/client/petstore/ruby/spec/models/inline_object3_spec.rb deleted file mode 100644 index 4daf41b4ace0..000000000000 --- a/samples/client/petstore/ruby/spec/models/inline_object3_spec.rb +++ /dev/null @@ -1,119 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject3 -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject3' do - before do - # run before each test - @instance = Petstore::InlineObject3.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject3' do - it 'should create an instance of InlineObject3' do - expect(@instance).to be_instance_of(Petstore::InlineObject3) - end - end - describe 'test attribute "integer"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "int32"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "int64"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "number"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "float"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "double"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "string"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "pattern_without_delimiter"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "byte"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "binary"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "date"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "date_time"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "password"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "callback"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end diff --git a/samples/client/petstore/ruby/spec/models/inline_object4_spec.rb b/samples/client/petstore/ruby/spec/models/inline_object4_spec.rb deleted file mode 100644 index fa806f95860c..000000000000 --- a/samples/client/petstore/ruby/spec/models/inline_object4_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject4 -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject4' do - before do - # run before each test - @instance = Petstore::InlineObject4.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject4' do - it 'should create an instance of InlineObject4' do - expect(@instance).to be_instance_of(Petstore::InlineObject4) - end - end - describe 'test attribute "param"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "param2"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end diff --git a/samples/client/petstore/ruby/spec/models/inline_object5_spec.rb b/samples/client/petstore/ruby/spec/models/inline_object5_spec.rb deleted file mode 100644 index e2410b21bc09..000000000000 --- a/samples/client/petstore/ruby/spec/models/inline_object5_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject5 -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject5' do - before do - # run before each test - @instance = Petstore::InlineObject5.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject5' do - it 'should create an instance of InlineObject5' do - expect(@instance).to be_instance_of(Petstore::InlineObject5) - end - end - describe 'test attribute "additional_metadata"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "required_file"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end diff --git a/samples/client/petstore/ruby/spec/models/inline_object_spec.rb b/samples/client/petstore/ruby/spec/models/inline_object_spec.rb deleted file mode 100644 index c5a7db44780e..000000000000 --- a/samples/client/petstore/ruby/spec/models/inline_object_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -=begin -#OpenAPI Petstore - -#This spec is mainly for testing Petstore server and contains fake endpoints, models. Please do not use this for any other purpose. Special characters: \" \\ - -The version of the OpenAPI document: 1.0.0 - -Generated by: https://openapi-generator.tech -OpenAPI Generator version: 5.0.0-SNAPSHOT - -=end - -require 'spec_helper' -require 'json' -require 'date' - -# Unit tests for Petstore::InlineObject -# Automatically generated by openapi-generator (https://openapi-generator.tech) -# Please update as you see appropriate -describe 'InlineObject' do - before do - # run before each test - @instance = Petstore::InlineObject.new - end - - after do - # run after each test - end - - describe 'test an instance of InlineObject' do - it 'should create an instance of InlineObject' do - expect(@instance).to be_instance_of(Petstore::InlineObject) - end - end - describe 'test attribute "name"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - - describe 'test attribute "status"' do - it 'should work' do - # assertion here. ref: https://www.relishapp.com/rspec/rspec-expectations/docs/built-in-matchers - end - end - -end