From ec6e74202988bf3399db3f95aa59344ae95fb27d Mon Sep 17 00:00:00 2001 From: fokot Date: Fri, 27 Dec 2019 11:10:25 +0100 Subject: [PATCH 1/5] scala set and default values for set and array. change from ListBuffer to List --- .../codegen/languages/AbstractKotlinCodegen.java | 4 ++-- .../codegen/languages/AbstractScalaCodegen.java | 10 +++++++--- .../codegen/languages/ScalaAkkaClientCodegen.java | 2 +- .../codegen/languages/ScalaGatlingCodegen.java | 3 +-- .../codegen/languages/ScalaHttpClientCodegen.java | 3 +-- .../codegen/languages/ScalaLagomServerCodegen.java | 3 +-- .../codegen/languages/ScalazClientCodegen.java | 4 +--- .../org/openapitools/codegen/utils/ModelUtils.java | 5 +++++ .../codegen/scalaakka/ScalaAkkaClientCodegenTest.java | 6 +++--- .../scalahttpclient/ScalaHttpClientModelTest.java | 10 +++++----- 10 files changed, 27 insertions(+), 23 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java index b0227feae164..9c8eb435e560 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractKotlinCodegen.java @@ -426,7 +426,7 @@ public void processOpts() { additionalProperties.put(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG, getSortParamsByRequiredFlag()); additionalProperties.put(CodegenConstants.SORT_MODEL_PROPERTIES_BY_REQUIRED_FLAG, getSortModelPropertiesByRequiredFlag()); - + additionalProperties.put(CodegenConstants.API_PACKAGE, apiPackage()); additionalProperties.put(CodegenConstants.MODEL_PACKAGE, modelPackage()); @@ -674,7 +674,7 @@ private String getArrayTypeDeclaration(ArraySchema arr) { // TODO: collection type here should be fully qualified namespace to avoid model conflicts // This supports arrays of arrays. String arrayType = typeMapping.get("array"); - if (Boolean.TRUE.equals(arr.getUniqueItems())) { + if (ModelUtils.isSet(arr)) { arrayType = typeMapping.get("set"); } StringBuilder instantiationType = new StringBuilder(arrayType); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java index e0ce0e8c9dda..6e63cd7c4eec 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java @@ -187,7 +187,9 @@ public String getTypeDeclaration(Schema p) { if (ModelUtils.isArraySchema(p)) { ArraySchema ap = (ArraySchema) p; Schema inner = ap.getItems(); - return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]"; + boolean isSet = ModelUtils.isSet(ap); + String arrayType = isSet ? typeMapping.get("set") : typeMapping.get("array"); + return arrayType + "[" + getTypeDeclaration(inner) + "]"; } else if (ModelUtils.isMapSchema(p)) { Schema inner = ModelUtils.getAdditionalProperties(p); @@ -228,6 +230,9 @@ public String toInstantiationType(Schema p) { @Override public String toDefaultValue(Schema p) { if (p.getDefault() != null) { + if (ModelUtils.isArraySchema(p) && p.getDefault().toString().equals("[]")) { + return ModelUtils.isSet((ArraySchema) p) ? "Set.empty " : "List.empty "; + } return p.getDefault().toString(); } @@ -247,8 +252,7 @@ public String toDefaultValue(Schema p) { return "new HashMap[String, " + inner + "]() "; } else if (ModelUtils.isArraySchema(p)) { ArraySchema ap = (ArraySchema) p; - String inner = getSchemaType(ap.getItems()); - return "new ListBuffer[" + inner + "]() "; + return ModelUtils.isSet(ap) ? "Set.empty " : "List.empty "; } else if (ModelUtils.isStringSchema(p)) { return null; } else { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java index a8f4327f9f91..56f46230a148 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java @@ -113,7 +113,7 @@ public ScalaAkkaClientCodegen() { typeMapping.put("binary", "File"); typeMapping.put("number", "Double"); - instantiationTypes.put("array", "ListBuffer"); + instantiationTypes.put("array", "List"); instantiationTypes.put("map", "Map"); cliOptions.add(new CliOption("mainPackage", "Top-level package name, which defines 'apiPackage', 'modelPackage', 'invokerPackage'").defaultValue("org.openapitools.client")); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java index 000430d1af5d..058901cd7506 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java @@ -151,7 +151,6 @@ public ScalaGatlingCodegen() { importMapping.remove("Map"); importMapping.put("Date", "java.util.Date"); - importMapping.put("ListBuffer", "scala.collection.mutable.ListBuffer"); typeMapping = new HashMap(); typeMapping.put("enum", "NSString"); @@ -173,7 +172,7 @@ public ScalaGatlingCodegen() { typeMapping.put("date-time", "Date"); typeMapping.put("DateTime", "Date"); - instantiationTypes.put("array", "ListBuffer"); + instantiationTypes.put("array", "List"); instantiationTypes.put("map", "HashMap"); setReservedWordsLowerCase( diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java index 637a5c819cc9..0615cc1c1188 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java @@ -110,7 +110,6 @@ public ScalaHttpClientCodegen() { importMapping.remove("Map"); importMapping.put("Date", "java.util.Date"); - importMapping.put("ListBuffer", "scala.collection.mutable.ListBuffer"); typeMapping = new HashMap(); typeMapping.put("enum", "NSString"); @@ -133,7 +132,7 @@ public ScalaHttpClientCodegen() { typeMapping.put("date-time", "Date"); typeMapping.put("DateTime", "Date"); - instantiationTypes.put("array", "ListBuffer"); + instantiationTypes.put("array", "List"); instantiationTypes.put("map", "HashMap"); cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase")); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java index 9b4651e601f6..ad61852d4cc2 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java @@ -76,7 +76,6 @@ public ScalaLagomServerCodegen() { importMapping.remove("Map"); importMapping.put("DateTime", "org.joda.time.DateTime"); - importMapping.put("ListBuffer", "scala.collection.mutable.ListBuffer"); typeMapping = new HashMap<>(); typeMapping.put("Integer", "Int"); @@ -100,7 +99,7 @@ public ScalaLagomServerCodegen() { typeMapping.put("binary", "String"); typeMapping.put("ByteArray", "String"); - instantiationTypes.put("array", "ListBuffer"); + instantiationTypes.put("array", "List"); instantiationTypes.put("map", "HashMap"); cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java index ec9cd9f2bf25..ce70f66502ec 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java @@ -76,8 +76,6 @@ public ScalazClientCodegen() { importMapping.remove("List"); importMapping.remove("Set"); importMapping.remove("Map"); - - importMapping.put("ListBuffer", "scala.collection.mutable.ListBuffer"); // Overrides defaults applied in DefaultCodegen which don't apply cleanly to Scala. importMapping.put("Date", "java.util.Date"); @@ -106,7 +104,7 @@ public ScalazClientCodegen() { typeMapping.put("date-time", "DateTime"); typeMapping.put("date", "DateTime"); - instantiationTypes.put("array", "ListBuffer"); + instantiationTypes.put("array", "List"); instantiationTypes.put("map", "HashMap"); additionalProperties.put("fnEnumEntry", new EnumEntryLambda()); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java index 89c84256d6ec..8f1de1296115 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java @@ -386,6 +386,11 @@ public static boolean isArraySchema(Schema schema) { return (schema instanceof ArraySchema); } + public static boolean isSet(ArraySchema schema) { + // schema.getUniqueItems() might return null :( + return Boolean.TRUE.equals(schema.getUniqueItems()); + } + public static boolean isStringSchema(Schema schema) { if (schema instanceof StringSchema || SchemaTypeUtil.STRING_TYPE.equals(schema.getType())) { return true; diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java index 9d3c52649864..4c0e6f1f33ea 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java @@ -257,9 +257,9 @@ public void arrayModelTest() { Assert.assertEquals(cm.classname, "Sample"); Assert.assertEquals(cm.description, "an array model"); Assert.assertEquals(cm.vars.size(), 0); - Assert.assertEquals(cm.parent, "ListBuffer[Children]"); - Assert.assertEquals(cm.imports.size(), 2); - Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("ListBuffer", "Children")).size(), 2); + Assert.assertEquals(cm.parent, "List[Children]"); + Assert.assertEquals(cm.imports.size(), 1); + Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1); } @Test(description = "convert a map model") diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalahttpclient/ScalaHttpClientModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalahttpclient/ScalaHttpClientModelTest.java index b3df6a5f81a8..97f7dc6012f1 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalahttpclient/ScalaHttpClientModelTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalahttpclient/ScalaHttpClientModelTest.java @@ -112,7 +112,7 @@ public void listPropertyTest() { Assert.assertEquals(property1.setter, "setUrls"); Assert.assertEquals(property1.dataType, "List[String]"); Assert.assertEquals(property1.name, "urls"); - Assert.assertEquals(property1.defaultValue, "new ListBuffer[String]() "); + Assert.assertEquals(property1.defaultValue, "List.empty "); Assert.assertEquals(property1.baseType, "List"); Assert.assertEquals(property1.containerType, "array"); Assert.assertFalse(property1.required); @@ -199,7 +199,7 @@ public void complexListPropertyTest() { Assert.assertEquals(property1.setter, "setChildren"); Assert.assertEquals(property1.dataType, "List[Children]"); Assert.assertEquals(property1.name, "children"); - Assert.assertEquals(property1.defaultValue, "new ListBuffer[Children]() "); + Assert.assertEquals(property1.defaultValue, "List.empty "); Assert.assertEquals(property1.baseType, "List"); Assert.assertEquals(property1.containerType, "array"); Assert.assertFalse(property1.required); @@ -251,9 +251,9 @@ public void arrayModelTest() { Assert.assertEquals(cm.classname, "Sample"); Assert.assertEquals(cm.description, "an array model"); Assert.assertEquals(cm.vars.size(), 0); - Assert.assertEquals(cm.parent, "ListBuffer[Children]"); - Assert.assertEquals(cm.imports.size(), 2); - Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("ListBuffer", "Children")).size(), 2); + Assert.assertEquals(cm.parent, "List[Children]"); + Assert.assertEquals(cm.imports.size(), 1); + Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1); } @Test(description = "convert a map model") From e8b46a994d9c2a6e84522e96f9733e2937bdf088 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sat, 4 Jan 2020 16:32:41 -0500 Subject: [PATCH 2/5] [scala] Better Set support for unique arrays This builds upon community contribution for better Set support in Scala. It makes property + model work as expected with Set and default values across all Scala generators. Included tests to account for new changes. This also reverts the community contribution to remove ListBuffer imports and change the default for array to ListBuffer. Users should use the instantiation types map to modify the desired array instantiation type. Any new default should target a new minor release after community discussion, as it affects all existing SDKs generated with openapi-generator. --- .../languages/AbstractScalaCodegen.java | 46 +++++++++---- .../languages/ScalaAkkaClientCodegen.java | 5 +- .../languages/ScalaGatlingCodegen.java | 2 +- .../languages/ScalaHttpClientCodegen.java | 2 +- .../languages/ScalaLagomServerCodegen.java | 2 +- .../ScalaPlayFrameworkServerCodegen.java | 5 +- .../languages/ScalazClientCodegen.java | 4 +- .../codegen/utils/ModelUtils.java | 5 +- .../scalaakka/ScalaAkkaClientCodegenTest.java | 60 ++++++++++++++++- .../ScalaHttpClientModelTest.java | 64 +++++++++++++++++-- .../codegen/utils/ModelUtilsTest.java | 24 +++++++ 11 files changed, 190 insertions(+), 29 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java index 6e63cd7c4eec..6e4fdfe45ca1 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java @@ -23,9 +23,7 @@ import io.swagger.v3.oas.models.media.Schema; import org.apache.commons.io.FilenameUtils; import org.apache.commons.lang3.StringUtils; -import org.openapitools.codegen.CliOption; -import org.openapitools.codegen.CodegenConstants; -import org.openapitools.codegen.DefaultCodegen; +import org.openapitools.codegen.*; import org.openapitools.codegen.utils.ModelUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -106,6 +104,10 @@ public AbstractScalaCodegen() { "yield" )); + importMapping.put("ListBuffer", "scala.collection.mutable.ListBuffer"); + importMapping.put("Set", "scala.collection.immutable.Set"); + instantiationTypes.put("set", "Set"); + cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.API_PACKAGE, CodegenConstants.API_PACKAGE_DESC)); cliOptions.add(new CliOption(CodegenConstants.SOURCE_FOLDER, CodegenConstants.SOURCE_FOLDER_DESC)); @@ -187,9 +189,7 @@ public String getTypeDeclaration(Schema p) { if (ModelUtils.isArraySchema(p)) { ArraySchema ap = (ArraySchema) p; Schema inner = ap.getItems(); - boolean isSet = ModelUtils.isSet(ap); - String arrayType = isSet ? typeMapping.get("set") : typeMapping.get("array"); - return arrayType + "[" + getTypeDeclaration(inner) + "]"; + return getSchemaType(p) + "[" + getTypeDeclaration(inner) + "]"; } else if (ModelUtils.isMapSchema(p)) { Schema inner = ModelUtils.getAdditionalProperties(p); @@ -201,6 +201,10 @@ public String getTypeDeclaration(Schema p) { @Override public String getSchemaType(Schema p) { String openAPIType = super.getSchemaType(p); + if (ModelUtils.isSet(p)) { + openAPIType = "set"; + } + String type = null; if (typeMapping.containsKey(openAPIType)) { type = typeMapping.get(openAPIType); @@ -221,7 +225,7 @@ public String toInstantiationType(Schema p) { } else if (ModelUtils.isArraySchema(p)) { ArraySchema ap = (ArraySchema) p; String inner = getSchemaType(ap.getItems()); - return instantiationTypes.get("array") + "[" + inner + "]"; + return ( ModelUtils.isSet(ap) ? instantiationTypes.get("set") : instantiationTypes.get("array") ) + "[" + inner + "]"; } else { return null; } @@ -230,9 +234,6 @@ public String toInstantiationType(Schema p) { @Override public String toDefaultValue(Schema p) { if (p.getDefault() != null) { - if (ModelUtils.isArraySchema(p) && p.getDefault().toString().equals("[]")) { - return ModelUtils.isSet((ArraySchema) p) ? "Set.empty " : "List.empty "; - } return p.getDefault().toString(); } @@ -252,7 +253,11 @@ public String toDefaultValue(Schema p) { return "new HashMap[String, " + inner + "]() "; } else if (ModelUtils.isArraySchema(p)) { ArraySchema ap = (ArraySchema) p; - return ModelUtils.isSet(ap) ? "Set.empty " : "List.empty "; + String inner = getSchemaType(ap.getItems()); + if (ModelUtils.isSet(ap)) { + return "Set[" + inner + "].empty "; + } + return "new ListBuffer[" + inner + "]() "; } else if (ModelUtils.isStringSchema(p)) { return null; } else { @@ -260,6 +265,25 @@ public String toDefaultValue(Schema p) { } } + /** + * Convert OAS Property object to Codegen Property object + * + * @param name name of the property + * @param p OAS property object + * @return Codegen Property object + */ + @Override + public CodegenProperty fromProperty(String name, Schema p) { + CodegenProperty prop = super.fromProperty(name, p); + if (ModelUtils.isArraySchema(p)) { + ArraySchema as = (ArraySchema) p; + if (ModelUtils.isSet(as)) { + prop.containerType = "set"; + } + } + return prop; + } + @Override public Map postProcessModels(Map objs) { // remove model imports to avoid warnings for importing class in the same package in Scala diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java index 56f46230a148..749ffeadd450 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaAkkaClientCodegen.java @@ -113,7 +113,7 @@ public ScalaAkkaClientCodegen() { typeMapping.put("binary", "File"); typeMapping.put("number", "Double"); - instantiationTypes.put("array", "List"); + instantiationTypes.put("array", "ListBuffer"); instantiationTypes.put("map", "Map"); cliOptions.add(new CliOption("mainPackage", "Top-level package name, which defines 'apiPackage', 'modelPackage', 'invokerPackage'").defaultValue("org.openapitools.client")); @@ -265,6 +265,9 @@ public String toDefaultValue(Schema p) { } else if (ModelUtils.isArraySchema(p)) { ArraySchema ap = (ArraySchema) p; String inner = getSchemaType(ap.getItems()); + if (ModelUtils.isSet(ap)) { + return "Set[" + inner + "].empty "; + } return "Seq[" + inner + "].empty "; } else if (ModelUtils.isStringSchema(p)) { return null; diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java index 058901cd7506..47af55762652 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaGatlingCodegen.java @@ -172,7 +172,7 @@ public ScalaGatlingCodegen() { typeMapping.put("date-time", "Date"); typeMapping.put("DateTime", "Date"); - instantiationTypes.put("array", "List"); + instantiationTypes.put("array", "ListBuffer"); instantiationTypes.put("map", "HashMap"); setReservedWordsLowerCase( diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java index 0615cc1c1188..433519a71070 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaHttpClientCodegen.java @@ -132,7 +132,7 @@ public ScalaHttpClientCodegen() { typeMapping.put("date-time", "Date"); typeMapping.put("DateTime", "Date"); - instantiationTypes.put("array", "List"); + instantiationTypes.put("array", "ListBuffer"); instantiationTypes.put("map", "HashMap"); cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, CodegenConstants.MODEL_PROPERTY_NAMING_DESC).defaultValue("camelCase")); diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java index ad61852d4cc2..2d331b2d314d 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalaLagomServerCodegen.java @@ -99,7 +99,7 @@ public ScalaLagomServerCodegen() { typeMapping.put("binary", "String"); typeMapping.put("ByteArray", "String"); - instantiationTypes.put("array", "List"); + instantiationTypes.put("array", "ListBuffer"); instantiationTypes.put("map", "HashMap"); cliOptions.add(new CliOption(CodegenConstants.MODEL_PROPERTY_NAMING, 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 1f02cc989f4d..b2453760a732 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 @@ -69,7 +69,7 @@ public ScalaPlayFrameworkServerCodegen() { modelPackage = "model"; instantiationTypes.put("map", "Map"); - instantiationTypes.put("array", "List"); + instantiationTypes.put("array", "ListBuffer"); typeMapping.put("DateTime", "OffsetDateTime"); typeMapping.put("Date", "LocalDate"); @@ -348,6 +348,9 @@ public String toDefaultValue(Schema p) { if (ModelUtils.isArraySchema(p)) { Schema items = ((ArraySchema) p).getItems(); String inner = getSchemaType(items); + if (ModelUtils.isSet(p)) { + return "Set.empty[" + inner + "]"; + } return "List.empty[" + inner + "]"; } diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java index ce70f66502ec..e385ccca2096 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalazClientCodegen.java @@ -104,7 +104,7 @@ public ScalazClientCodegen() { typeMapping.put("date-time", "DateTime"); typeMapping.put("date", "DateTime"); - instantiationTypes.put("array", "List"); + instantiationTypes.put("array", "ListBuffer"); instantiationTypes.put("map", "HashMap"); additionalProperties.put("fnEnumEntry", new EnumEntryLambda()); @@ -212,7 +212,7 @@ public String toDefaultValue(Schema p) { } else if (ModelUtils.isArraySchema(p)) { ArraySchema ap = (ArraySchema) p; String inner = getSchemaType(ap.getItems()); - String collectionType = typeMapping.get("array"); + String collectionType = ModelUtils.isSet(ap) ? typeMapping.get("set") : typeMapping.get("array"); // We assume that users would map these collections to a monoid with an identity function // There's no reason to assume mutable structure here (which may make consumption more difficult) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java index 8f1de1296115..6b02731d1228 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/utils/ModelUtils.java @@ -386,9 +386,8 @@ public static boolean isArraySchema(Schema schema) { return (schema instanceof ArraySchema); } - public static boolean isSet(ArraySchema schema) { - // schema.getUniqueItems() might return null :( - return Boolean.TRUE.equals(schema.getUniqueItems()); + public static boolean isSet(Schema schema) { + return ModelUtils.isArraySchema(schema) && Boolean.TRUE.equals(schema.getUniqueItems()); } public static boolean isStringSchema(Schema schema) { diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java index 4c0e6f1f33ea..d4e657b5fc7a 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalaakka/ScalaAkkaClientCodegenTest.java @@ -212,6 +212,37 @@ public void complexListPropertyTest() { Assert.assertTrue(property1.isContainer); } + @Test(description = "convert a model with set (unique array) property") + public void complexSetPropertyTest() { + final Schema model = new Schema() + .description("a sample model") + .addProperties("children", new ArraySchema() + .items(new Schema().$ref("#/definitions/Children")) + .uniqueItems(Boolean.TRUE)); + final DefaultCodegen codegen = new ScalaAkkaClientCodegen(); + OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model); + codegen.setOpenAPI(openAPI); + final CodegenModel cm = codegen.fromModel("sample", model); + + Assert.assertEquals(cm.name, "sample"); + Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.description, "a sample model"); + Assert.assertEquals(cm.vars.size(), 1); + + final CodegenProperty property1 = cm.vars.get(0); + Assert.assertEquals(property1.baseName, "children"); + Assert.assertEquals(property1.complexType, "Children"); + Assert.assertEquals(property1.getter, "getChildren"); + Assert.assertEquals(property1.setter, "setChildren"); + Assert.assertEquals(property1.dataType, "Set[Children]"); + Assert.assertEquals(property1.name, "children"); + Assert.assertEquals(property1.defaultValue, "Set[Children].empty "); + Assert.assertEquals(property1.baseType, "Set"); + Assert.assertEquals(property1.containerType, "set"); + Assert.assertFalse(property1.required); + Assert.assertTrue(property1.isContainer); + } + @Test(description = "convert a model with complex map property") public void complexMapPropertyTest() { final Schema model = new Schema() @@ -257,9 +288,32 @@ public void arrayModelTest() { Assert.assertEquals(cm.classname, "Sample"); Assert.assertEquals(cm.description, "an array model"); Assert.assertEquals(cm.vars.size(), 0); - Assert.assertEquals(cm.parent, "List[Children]"); - Assert.assertEquals(cm.imports.size(), 1); - Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1); + Assert.assertEquals(cm.parent, "ListBuffer[Children]"); + Assert.assertEquals(cm.arrayModelType, "Children"); + Assert.assertEquals(cm.imports.size(), 2); + Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("ListBuffer", "Children")).size(), 2); + } + + @Test(description = "convert an array model with unique items to set") + public void arrayAsSetModelTest() { + final Schema schema = new ArraySchema() + .items(new Schema().$ref("#/definitions/Children")) + .description("a set of Children models"); + schema.setUniqueItems(true); + + final DefaultCodegen codegen = new ScalaAkkaClientCodegen(); + OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema); + codegen.setOpenAPI(openAPI); + final CodegenModel cm = codegen.fromModel("sample", schema); + + Assert.assertEquals(cm.name, "sample"); + Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.description, "a set of Children models"); + Assert.assertEquals(cm.vars.size(), 0); + Assert.assertEquals(cm.parent, "Set[Children]"); + Assert.assertEquals(cm.arrayModelType, "Children"); + Assert.assertEquals(cm.imports.size(), 2); + Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Set", "Children")).size(), 2); } @Test(description = "convert a map model") diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalahttpclient/ScalaHttpClientModelTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalahttpclient/ScalaHttpClientModelTest.java index 97f7dc6012f1..1b91375a3c27 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalahttpclient/ScalaHttpClientModelTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/scalahttpclient/ScalaHttpClientModelTest.java @@ -25,6 +25,7 @@ import org.openapitools.codegen.CodegenProperty; import org.openapitools.codegen.DefaultCodegen; import org.openapitools.codegen.TestUtils; +import org.openapitools.codegen.languages.ScalaAkkaClientCodegen; import org.openapitools.codegen.languages.ScalaHttpClientCodegen; import org.testng.Assert; import org.testng.annotations.Test; @@ -112,13 +113,44 @@ public void listPropertyTest() { Assert.assertEquals(property1.setter, "setUrls"); Assert.assertEquals(property1.dataType, "List[String]"); Assert.assertEquals(property1.name, "urls"); - Assert.assertEquals(property1.defaultValue, "List.empty "); + Assert.assertEquals(property1.defaultValue, "new ListBuffer[String]() "); Assert.assertEquals(property1.baseType, "List"); Assert.assertEquals(property1.containerType, "array"); Assert.assertFalse(property1.required); Assert.assertTrue(property1.isContainer); } + @Test(description = "convert a model with set (unique array) property") + public void complexSetPropertyTest() { + final Schema model = new Schema() + .description("a sample model") + .addProperties("children", new ArraySchema() + .items(new Schema().$ref("#/definitions/Children")) + .uniqueItems(Boolean.TRUE)); + final DefaultCodegen codegen = new ScalaHttpClientCodegen(); + OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", model); + codegen.setOpenAPI(openAPI); + final CodegenModel cm = codegen.fromModel("sample", model); + + Assert.assertEquals(cm.name, "sample"); + Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.description, "a sample model"); + Assert.assertEquals(cm.vars.size(), 1); + + final CodegenProperty property1 = cm.vars.get(0); + Assert.assertEquals(property1.baseName, "children"); + Assert.assertEquals(property1.complexType, "Children"); + Assert.assertEquals(property1.getter, "getChildren"); + Assert.assertEquals(property1.setter, "setChildren"); + Assert.assertEquals(property1.dataType, "Set[Children]"); + Assert.assertEquals(property1.name, "children"); + Assert.assertEquals(property1.defaultValue, "Set[Children].empty "); + Assert.assertEquals(property1.baseType, "Set"); + Assert.assertEquals(property1.containerType, "set"); + Assert.assertFalse(property1.required); + Assert.assertTrue(property1.isContainer); + } + @Test(description = "convert a model with a map property") public void mapPropertyTest() { final Schema model = new Schema() @@ -199,7 +231,7 @@ public void complexListPropertyTest() { Assert.assertEquals(property1.setter, "setChildren"); Assert.assertEquals(property1.dataType, "List[Children]"); Assert.assertEquals(property1.name, "children"); - Assert.assertEquals(property1.defaultValue, "List.empty "); + Assert.assertEquals(property1.defaultValue, "new ListBuffer[Children]() "); Assert.assertEquals(property1.baseType, "List"); Assert.assertEquals(property1.containerType, "array"); Assert.assertFalse(property1.required); @@ -251,9 +283,31 @@ public void arrayModelTest() { Assert.assertEquals(cm.classname, "Sample"); Assert.assertEquals(cm.description, "an array model"); Assert.assertEquals(cm.vars.size(), 0); - Assert.assertEquals(cm.parent, "List[Children]"); - Assert.assertEquals(cm.imports.size(), 1); - Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Children")).size(), 1); + Assert.assertEquals(cm.parent, "ListBuffer[Children]"); + Assert.assertEquals(cm.imports.size(), 2); + Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("ListBuffer", "Children")).size(), 2); + } + + @Test(description = "convert an array model with unique items to set") + public void arrayAsSetModelTest() { + final Schema schema = new ArraySchema() + .items(new Schema().$ref("#/definitions/Children")) + .description("a set of Children models"); + schema.setUniqueItems(true); + + final DefaultCodegen codegen = new ScalaHttpClientCodegen(); + OpenAPI openAPI = TestUtils.createOpenAPIWithOneSchema("sample", schema); + codegen.setOpenAPI(openAPI); + final CodegenModel cm = codegen.fromModel("sample", schema); + + Assert.assertEquals(cm.name, "sample"); + Assert.assertEquals(cm.classname, "Sample"); + Assert.assertEquals(cm.description, "a set of Children models"); + Assert.assertEquals(cm.vars.size(), 0); + Assert.assertEquals(cm.parent, "Set[Children]"); + Assert.assertEquals(cm.arrayModelType, "Children"); + Assert.assertEquals(cm.imports.size(), 2); + Assert.assertEquals(Sets.intersection(cm.imports, Sets.newHashSet("Set", "Children")).size(), 2); } @Test(description = "convert a map model") diff --git a/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/ModelUtilsTest.java b/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/ModelUtilsTest.java index 8e20b035a55c..7d4b9f8fb9b2 100644 --- a/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/ModelUtilsTest.java +++ b/modules/openapi-generator/src/test/java/org/openapitools/codegen/utils/ModelUtilsTest.java @@ -235,4 +235,28 @@ public void testIsFreeFormObject() { // Test a null schema Assert.assertFalse(ModelUtils.isFreeFormObject(null)); } + + @Test + public void testIsSetForValidSet() { + ArraySchema as = new ArraySchema() + .items(new StringSchema()); + as.setUniqueItems(true); + + Assert.assertTrue(ModelUtils.isSet(as)); + } + + @Test + public void testIsSetFalseForInvalidSet() { + ArraySchema as = new ArraySchema() + .items(new StringSchema()); + as.setUniqueItems(false); + + Assert.assertFalse(ModelUtils.isSet(as)); + } + + @Test + public void testIsSetFailsForNullSchema() { + ArraySchema as = null; + Assert.assertFalse(ModelUtils.isSet(as)); + } } From f721bcef59c07c175f2ea24d6c8022b9c0a56438 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sat, 4 Jan 2020 18:26:34 -0500 Subject: [PATCH 3/5] [scala] Improve default handling of monadic collection type --- .../languages/AbstractScalaCodegen.java | 28 +++++++++++++++++-- .../languages/ScalatraServerCodegen.java | 21 ++++++++++++-- 2 files changed, 44 insertions(+), 5 deletions(-) diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java index 6e4fdfe45ca1..80d17966d520 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractScalaCodegen.java @@ -105,7 +105,11 @@ public AbstractScalaCodegen() { )); importMapping.put("ListBuffer", "scala.collection.mutable.ListBuffer"); + // although Seq is a predef, before Scala 2.13, it _could_ refer to a mutable Seq in some cases. + importMapping.put("Seq", "scala.collection.immutable.Seq"); importMapping.put("Set", "scala.collection.immutable.Set"); + importMapping.put("ListSet", "scala.collection.immutable.ListSet"); + instantiationTypes.put("set", "Set"); cliOptions.add(new CliOption(CodegenConstants.MODEL_PACKAGE, CodegenConstants.MODEL_PACKAGE_DESC)); @@ -205,7 +209,7 @@ public String getSchemaType(Schema p) { openAPIType = "set"; } - String type = null; + String type; if (typeMapping.containsKey(openAPIType)) { type = typeMapping.get(openAPIType); if (languageSpecificPrimitives.contains(type)) { @@ -254,10 +258,28 @@ public String toDefaultValue(Schema p) { } else if (ModelUtils.isArraySchema(p)) { ArraySchema ap = (ArraySchema) p; String inner = getSchemaType(ap.getItems()); + String genericType; if (ModelUtils.isSet(ap)) { - return "Set[" + inner + "].empty "; + genericType = instantiationTypes.get("set"); + } else { + genericType = instantiationTypes.get("array"); + } + + // test for immutable Monoids with .empty method for idiomatic defaults + if ("List".equals(genericType) || + "Set".equals(genericType) || + "Seq".equals(genericType) || + "Array".equals(genericType) || + "Vector".equals(genericType) || + "IndexedSeq".equals(genericType) || + "Iterable".equals(genericType) || + "ListSet".equals(genericType) + ) { + return genericType + "[" + inner + "].empty "; } - return "new ListBuffer[" + inner + "]() "; + + // Assume that any other generic types can be new'd up. + return "new " + genericType + "[" + inner + "]() "; } else if (ModelUtils.isStringSchema(p)) { return null; } else { diff --git a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalatraServerCodegen.java b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalatraServerCodegen.java index 806157ce87dd..91176fbf25ac 100644 --- a/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalatraServerCodegen.java +++ b/modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/ScalatraServerCodegen.java @@ -63,14 +63,27 @@ public ScalatraServerCodegen() { "Integer", "Long", "Float", - "List", "Set", "Map") ); + typeMapping = new HashMap<>(); + typeMapping.put("array", "List"); + typeMapping.put("set", "Set"); + typeMapping.put("boolean", "Boolean"); + typeMapping.put("string", "String"); + typeMapping.put("int", "Int"); typeMapping.put("integer", "Int"); typeMapping.put("long", "Long"); + typeMapping.put("float", "Float"); + typeMapping.put("byte", "Byte"); + typeMapping.put("short", "Short"); + typeMapping.put("char", "Char"); + typeMapping.put("double", "Double"); + typeMapping.put("object", "Any"); + typeMapping.put("file", "File"); typeMapping.put("binary", "File"); + typeMapping.put("number", "Double"); additionalProperties.put("appName", "OpenAPI Sample"); additionalProperties.put("appDescription", "A sample openapi server"); @@ -95,7 +108,6 @@ public ScalatraServerCodegen() { supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt")); supportingFiles.add(new SupportingFile("sbt", "", "sbt")); - instantiationTypes.put("array", "ArrayList"); instantiationTypes.put("map", "HashMap"); importMapping = new HashMap(); @@ -113,6 +125,11 @@ public ScalatraServerCodegen() { importMapping.put("LocalDateTime", "org.joda.time.LocalDateTime"); importMapping.put("LocalDate", "org.joda.time.LocalDate"); importMapping.put("LocalTime", "org.joda.time.LocalTime"); + importMapping.put("ListBuffer", "scala.collection.mutable.ListBuffer"); + importMapping.put("Set", "scala.collection.immutable.Set"); + importMapping.put("ListSet", "scala.collection.immutable.ListSet"); + + instantiationTypes.put("set", "Set"); } @Override From 6b2bd636dba6094918b1a4685cf6495a3aa80703 Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sat, 4 Jan 2020 23:10:49 -0500 Subject: [PATCH 4/5] [scala] Regenerate samples --- .../scala-akka/.openapi-generator/VERSION | 2 +- .../scala-gatling/.openapi-generator/VERSION | 2 +- .../resources/data/loginUser-queryParams.csv | 2 +- .../client/api/UserApiSimulation.scala | 2 +- .../.openapi-generator/VERSION | 2 +- .../petstore/scala-httpclient/git_push.sh | 16 +- .../scalaz/.openapi-generator/VERSION | 2 +- .../petstore/scalaz/project/build.properties | 2 +- .../.openapi-generator/VERSION | 2 +- .../petstore/scala-lagom-server/README.md | 8 +- .../petstore/scala-lagom-server/build.sbt | 2 +- .../scala/io/swagger/client/api/PetApi.scala | 12 +- .../io/swagger/client/api/StoreApi.scala | 12 +- .../scala/io/swagger/client/api/UserApi.scala | 14 +- .../io/swagger/client/model/ApiResponse.scala | 14 +- .../io/swagger/client/model/Category.scala | 12 +- .../scala/io/swagger/client/model/Order.scala | 12 +- .../scala/io/swagger/client/model/Pet.scala | 12 +- .../scala/io/swagger/client/model/Tag.scala | 12 +- .../scala/io/swagger/client/model/User.scala | 12 +- .../.openapi-generator/VERSION | 2 +- .../petstore/scala-play-server/README.md | 2 +- .../scala-play-server/app/api/PetApi.scala | 2 +- .../app/api/PetApiController.scala | 2 +- .../app/api/PetApiImpl.scala | 2 +- .../scala-play-server/app/api/StoreApi.scala | 2 +- .../app/api/StoreApiController.scala | 2 +- .../app/api/StoreApiImpl.scala | 2 +- .../scala-play-server/app/api/UserApi.scala | 2 +- .../app/api/UserApiController.scala | 2 +- .../app/api/UserApiImpl.scala | 2 +- .../app/model/ApiResponse.scala | 2 +- .../app/model/Category.scala | 2 +- .../scala-play-server/app/model/Order.scala | 2 +- .../scala-play-server/app/model/Pet.scala | 2 +- .../scala-play-server/app/model/Tag.scala | 2 +- .../scala-play-server/app/model/User.scala | 2 +- .../app/org/openapitools/Module.scala | 2 +- .../scala-play-server/public/openapi.json | 774 +++++++++--------- 39 files changed, 485 insertions(+), 479 deletions(-) diff --git a/samples/client/petstore/scala-akka/.openapi-generator/VERSION b/samples/client/petstore/scala-akka/.openapi-generator/VERSION index 0e97bd19efbf..58592f031f65 100644 --- a/samples/client/petstore/scala-akka/.openapi-generator/VERSION +++ b/samples/client/petstore/scala-akka/.openapi-generator/VERSION @@ -1 +1 @@ -4.1.3-SNAPSHOT \ No newline at end of file +4.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/scala-gatling/.openapi-generator/VERSION b/samples/client/petstore/scala-gatling/.openapi-generator/VERSION index 096bf47efe31..58592f031f65 100644 --- a/samples/client/petstore/scala-gatling/.openapi-generator/VERSION +++ b/samples/client/petstore/scala-gatling/.openapi-generator/VERSION @@ -1 +1 @@ -3.0.0-SNAPSHOT \ No newline at end of file +4.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/scala-gatling/src/gatling/resources/data/loginUser-queryParams.csv b/samples/client/petstore/scala-gatling/src/gatling/resources/data/loginUser-queryParams.csv index d8bc9aec67d0..418fd574de51 100644 --- a/samples/client/petstore/scala-gatling/src/gatling/resources/data/loginUser-queryParams.csv +++ b/samples/client/petstore/scala-gatling/src/gatling/resources/data/loginUser-queryParams.csv @@ -1 +1 @@ -username,password \ No newline at end of file +password,username \ No newline at end of file diff --git a/samples/client/petstore/scala-gatling/src/gatling/scala/org/openapitools/client/api/UserApiSimulation.scala b/samples/client/petstore/scala-gatling/src/gatling/scala/org/openapitools/client/api/UserApiSimulation.scala index c12112e8b0da..6b97d7c04907 100644 --- a/samples/client/petstore/scala-gatling/src/gatling/scala/org/openapitools/client/api/UserApiSimulation.scala +++ b/samples/client/petstore/scala-gatling/src/gatling/scala/org/openapitools/client/api/UserApiSimulation.scala @@ -147,8 +147,8 @@ class UserApiSimulation extends Simulation { .feed(loginUserQUERYFeeder) .exec(http("loginUser") .httpRequest("GET","/user/login") - .queryParam("username","${username}") .queryParam("password","${password}") + .queryParam("username","${username}") ) // Run scnloginUser with warm up and reach a constant rate for entire duration diff --git a/samples/client/petstore/scala-httpclient/.openapi-generator/VERSION b/samples/client/petstore/scala-httpclient/.openapi-generator/VERSION index 06b5019af3f4..58592f031f65 100644 --- a/samples/client/petstore/scala-httpclient/.openapi-generator/VERSION +++ b/samples/client/petstore/scala-httpclient/.openapi-generator/VERSION @@ -1 +1 @@ -4.0.1-SNAPSHOT \ No newline at end of file +4.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/scala-httpclient/git_push.sh b/samples/client/petstore/scala-httpclient/git_push.sh index 8442b80bb445..ced3be2b0c7b 100644 --- a/samples/client/petstore/scala-httpclient/git_push.sh +++ b/samples/client/petstore/scala-httpclient/git_push.sh @@ -1,11 +1,17 @@ #!/bin/sh # ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/ # -# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" +# Usage example: /bin/sh ./git_push.sh wing328 openapi-pestore-perl "minor update" "gitlab.com" git_user_id=$1 git_repo_id=$2 release_note=$3 +git_host=$4 + +if [ "$git_host" = "" ]; then + git_host="github.com" + echo "[INFO] No command line input provided. Set \$git_host to $git_host" +fi if [ "$git_user_id" = "" ]; then git_user_id="GIT_USER_ID" @@ -28,7 +34,7 @@ git init # Adds the files in the local repository and stages them for commit. git add . -# Commits the tracked changes and prepares them to be pushed to a remote repository. +# Commits the tracked changes and prepares them to be pushed to a remote repository. git commit -m "$release_note" # Sets the new remote @@ -37,9 +43,9 @@ if [ "$git_remote" = "" ]; then # git remote not defined if [ "$GIT_TOKEN" = "" ]; then echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment." - git remote add origin https://github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git else - git remote add origin https://${git_user_id}:${GIT_TOKEN}@github.com/${git_user_id}/${git_repo_id}.git + git remote add origin https://${git_user_id}:${GIT_TOKEN}@${git_host}/${git_user_id}/${git_repo_id}.git fi fi @@ -47,6 +53,6 @@ fi git pull origin master # Pushes (Forces) the changes in the local repository up to the remote repository -echo "Git pushing to https://github.com/${git_user_id}/${git_repo_id}.git" +echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git" git push origin master 2>&1 | grep -v 'To https' diff --git a/samples/client/petstore/scalaz/.openapi-generator/VERSION b/samples/client/petstore/scalaz/.openapi-generator/VERSION index e4955748d3e7..58592f031f65 100644 --- a/samples/client/petstore/scalaz/.openapi-generator/VERSION +++ b/samples/client/petstore/scalaz/.openapi-generator/VERSION @@ -1 +1 @@ -4.2.2-SNAPSHOT \ No newline at end of file +4.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/scalaz/project/build.properties b/samples/client/petstore/scalaz/project/build.properties index 64317fdae59f..cf19fd026fd1 100644 --- a/samples/client/petstore/scalaz/project/build.properties +++ b/samples/client/petstore/scalaz/project/build.properties @@ -1 +1 @@ -sbt.version=0.13.15 +sbt.version=0.13.15 \ No newline at end of file diff --git a/samples/server/petstore/scala-lagom-server/.openapi-generator/VERSION b/samples/server/petstore/scala-lagom-server/.openapi-generator/VERSION index f9f7450d1359..58592f031f65 100644 --- a/samples/server/petstore/scala-lagom-server/.openapi-generator/VERSION +++ b/samples/server/petstore/scala-lagom-server/.openapi-generator/VERSION @@ -1 +1 @@ -2.3.0-SNAPSHOT \ No newline at end of file +4.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/scala-lagom-server/README.md b/samples/server/petstore/scala-lagom-server/README.md index 938d7331cb7d..e80ddccb7e17 100644 --- a/samples/server/petstore/scala-lagom-server/README.md +++ b/samples/server/petstore/scala-lagom-server/README.md @@ -1,9 +1,9 @@ -# Swagger generated scala-lagomApi +# OpenAPI generated scala-lagomApi ## Overview -This server was generated by the [swagger-codegen](https://github.com/swagger-api/swagger-codegen) project. By using the -[OpenAPI-Spec](https://github.com/swagger-api/swagger-core/wiki) from a remote server, you can easily generate a server stub. This -is an example of building a swagger-enabled lagon-api. +This server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the +[OpenAPI-Spec](https://openapis.org) from a remote server, you can easily generate a server stub. This +is an example of building a OpenAPI-enabled lagon-api. This example uses the [lagomframework](https://www.lagomframework.com) lagomframework. diff --git a/samples/server/petstore/scala-lagom-server/build.sbt b/samples/server/petstore/scala-lagom-server/build.sbt index ea9dd5789f03..b6ab43cf17b3 100644 --- a/samples/server/petstore/scala-lagom-server/build.sbt +++ b/samples/server/petstore/scala-lagom-server/build.sbt @@ -2,7 +2,7 @@ version := "1.0.0" name := "scala-lagom-server" -organization := "io.swagger" +organization := "org.openapitools" scalaVersion := "2.11.8" diff --git a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/PetApi.scala b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/PetApi.scala index 6ee03b22acac..559f0820c428 100644 --- a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/PetApi.scala +++ b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/PetApi.scala @@ -1,12 +1,12 @@ /** - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * The version of the OpenAPI document: 1.0.0 + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/StoreApi.scala b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/StoreApi.scala index ff42a995e9ae..2386c182986d 100644 --- a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/StoreApi.scala +++ b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/StoreApi.scala @@ -1,12 +1,12 @@ /** - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * The version of the OpenAPI document: 1.0.0 + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/UserApi.scala b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/UserApi.scala index b62b48d87504..211db9974bfb 100644 --- a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/UserApi.scala +++ b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/api/UserApi.scala @@ -1,12 +1,12 @@ /** - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * The version of the OpenAPI document: 1.0.0 + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ @@ -75,7 +75,7 @@ trait UserApi extends Service { * Get user by user name * * - * @param username The name that needs to be fetched. Use user1 for testing. + * @param username The name that needs to be fetched. Use user1 for testing. * @return User */ def getUserByName(username: String): ServiceCall[NotUsed ,User] diff --git a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/ApiResponse.scala b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/ApiResponse.scala index 884853e5c25b..28448672d579 100644 --- a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/ApiResponse.scala +++ b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/ApiResponse.scala @@ -1,12 +1,12 @@ /** - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * The version of the OpenAPI document: 1.0.0 + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ @@ -15,7 +15,7 @@ import play.api.libs.json._ case class ApiResponse ( code: Option[Int], - _type: Option[String], + `type`: Option[String], message: Option[String] ) diff --git a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Category.scala b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Category.scala index c50c6e71c64d..68f37da0d9e2 100644 --- a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Category.scala +++ b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Category.scala @@ -1,12 +1,12 @@ /** - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * The version of the OpenAPI document: 1.0.0 + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Order.scala b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Order.scala index c79ffb780e54..1f86d47b25be 100644 --- a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Order.scala +++ b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Order.scala @@ -1,12 +1,12 @@ /** - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * The version of the OpenAPI document: 1.0.0 + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Pet.scala b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Pet.scala index acc6c25afc38..56798d01eef0 100644 --- a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Pet.scala +++ b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Pet.scala @@ -1,12 +1,12 @@ /** - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * The version of the OpenAPI document: 1.0.0 + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Tag.scala b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Tag.scala index 65aa9c628bcd..8d8da70ff8ae 100644 --- a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Tag.scala +++ b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/Tag.scala @@ -1,12 +1,12 @@ /** - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * The version of the OpenAPI document: 1.0.0 + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/User.scala b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/User.scala index b21cd2e7e770..f5de40df3690 100644 --- a/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/User.scala +++ b/samples/server/petstore/scala-lagom-server/src/main/scala/io/swagger/client/model/User.scala @@ -1,12 +1,12 @@ /** - * Swagger Petstore - * This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters. + * OpenAPI Petstore + * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. * - * OpenAPI spec version: 1.0.0 - * Contact: apiteam@swagger.io + * The version of the OpenAPI document: 1.0.0 + * * - * NOTE: This class is auto generated by the swagger code generator program. - * https://github.com/swagger-api/swagger-codegen.git + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech * Do not edit the class manually. */ diff --git a/samples/server/petstore/scala-play-server/.openapi-generator/VERSION b/samples/server/petstore/scala-play-server/.openapi-generator/VERSION index afa636560641..58592f031f65 100644 --- a/samples/server/petstore/scala-play-server/.openapi-generator/VERSION +++ b/samples/server/petstore/scala-play-server/.openapi-generator/VERSION @@ -1 +1 @@ -4.0.0-SNAPSHOT \ No newline at end of file +4.2.3-SNAPSHOT \ No newline at end of file diff --git a/samples/server/petstore/scala-play-server/README.md b/samples/server/petstore/scala-play-server/README.md index 7f342575759e..87528aac7f01 100644 --- a/samples/server/petstore/scala-play-server/README.md +++ b/samples/server/petstore/scala-play-server/README.md @@ -2,7 +2,7 @@ This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. -This Scala Play Framework project was generated by the OpenAPI generator tool at 2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]. +This Scala Play Framework project was generated by the OpenAPI generator tool at 2020-01-04T23:10:22.106-05:00[America/New_York]. ## API diff --git a/samples/server/petstore/scala-play-server/app/api/PetApi.scala b/samples/server/petstore/scala-play-server/app/api/PetApi.scala index 1f7eaed70b40..ec7dc810a4b6 100644 --- a/samples/server/petstore/scala-play-server/app/api/PetApi.scala +++ b/samples/server/petstore/scala-play-server/app/api/PetApi.scala @@ -4,7 +4,7 @@ import model.ApiResponse import model.Pet import play.api.libs.Files.TemporaryFile -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") trait PetApi { /** * Add a new pet to the store diff --git a/samples/server/petstore/scala-play-server/app/api/PetApiController.scala b/samples/server/petstore/scala-play-server/app/api/PetApiController.scala index 33f07975634d..36d5ff287fd4 100644 --- a/samples/server/petstore/scala-play-server/app/api/PetApiController.scala +++ b/samples/server/petstore/scala-play-server/app/api/PetApiController.scala @@ -8,7 +8,7 @@ import model.ApiResponse import model.Pet import play.api.libs.Files.TemporaryFile -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") @Singleton class PetApiController @Inject()(cc: ControllerComponents, api: PetApi) extends AbstractController(cc) { /** diff --git a/samples/server/petstore/scala-play-server/app/api/PetApiImpl.scala b/samples/server/petstore/scala-play-server/app/api/PetApiImpl.scala index d3a8ea67b1bb..b5186deba44d 100644 --- a/samples/server/petstore/scala-play-server/app/api/PetApiImpl.scala +++ b/samples/server/petstore/scala-play-server/app/api/PetApiImpl.scala @@ -7,7 +7,7 @@ import play.api.libs.Files.TemporaryFile /** * Provides a default implementation for [[PetApi]]. */ -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") class PetApiImpl extends PetApi { /** * @inheritdoc diff --git a/samples/server/petstore/scala-play-server/app/api/StoreApi.scala b/samples/server/petstore/scala-play-server/app/api/StoreApi.scala index 11ee20112683..3197b95ed814 100644 --- a/samples/server/petstore/scala-play-server/app/api/StoreApi.scala +++ b/samples/server/petstore/scala-play-server/app/api/StoreApi.scala @@ -2,7 +2,7 @@ package api import model.Order -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") trait StoreApi { /** * Delete purchase order by ID diff --git a/samples/server/petstore/scala-play-server/app/api/StoreApiController.scala b/samples/server/petstore/scala-play-server/app/api/StoreApiController.scala index 161cf5805c68..f36218bd62d6 100644 --- a/samples/server/petstore/scala-play-server/app/api/StoreApiController.scala +++ b/samples/server/petstore/scala-play-server/app/api/StoreApiController.scala @@ -6,7 +6,7 @@ import play.api.libs.json._ import play.api.mvc._ import model.Order -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") @Singleton class StoreApiController @Inject()(cc: ControllerComponents, api: StoreApi) extends AbstractController(cc) { /** diff --git a/samples/server/petstore/scala-play-server/app/api/StoreApiImpl.scala b/samples/server/petstore/scala-play-server/app/api/StoreApiImpl.scala index 8a996a93e462..efe32363e9cd 100644 --- a/samples/server/petstore/scala-play-server/app/api/StoreApiImpl.scala +++ b/samples/server/petstore/scala-play-server/app/api/StoreApiImpl.scala @@ -5,7 +5,7 @@ import model.Order /** * Provides a default implementation for [[StoreApi]]. */ -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") class StoreApiImpl extends StoreApi { /** * @inheritdoc diff --git a/samples/server/petstore/scala-play-server/app/api/UserApi.scala b/samples/server/petstore/scala-play-server/app/api/UserApi.scala index 41b24e87562a..df0471d833f5 100644 --- a/samples/server/petstore/scala-play-server/app/api/UserApi.scala +++ b/samples/server/petstore/scala-play-server/app/api/UserApi.scala @@ -2,7 +2,7 @@ package api import model.User -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") trait UserApi { /** * Create user diff --git a/samples/server/petstore/scala-play-server/app/api/UserApiController.scala b/samples/server/petstore/scala-play-server/app/api/UserApiController.scala index 05550df7c665..2675c44bafa6 100644 --- a/samples/server/petstore/scala-play-server/app/api/UserApiController.scala +++ b/samples/server/petstore/scala-play-server/app/api/UserApiController.scala @@ -6,7 +6,7 @@ import play.api.libs.json._ import play.api.mvc._ import model.User -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") @Singleton class UserApiController @Inject()(cc: ControllerComponents, api: UserApi) extends AbstractController(cc) { /** diff --git a/samples/server/petstore/scala-play-server/app/api/UserApiImpl.scala b/samples/server/petstore/scala-play-server/app/api/UserApiImpl.scala index 01ce46e98e55..b14446f643f4 100644 --- a/samples/server/petstore/scala-play-server/app/api/UserApiImpl.scala +++ b/samples/server/petstore/scala-play-server/app/api/UserApiImpl.scala @@ -5,7 +5,7 @@ import model.User /** * Provides a default implementation for [[UserApi]]. */ -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") class UserApiImpl extends UserApi { /** * @inheritdoc diff --git a/samples/server/petstore/scala-play-server/app/model/ApiResponse.scala b/samples/server/petstore/scala-play-server/app/model/ApiResponse.scala index 529462aa0864..956360fa5ea1 100644 --- a/samples/server/petstore/scala-play-server/app/model/ApiResponse.scala +++ b/samples/server/petstore/scala-play-server/app/model/ApiResponse.scala @@ -5,7 +5,7 @@ import play.api.libs.json._ /** * Describes the result of uploading an image resource */ -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") case class ApiResponse( code: Option[Int], `type`: Option[String], diff --git a/samples/server/petstore/scala-play-server/app/model/Category.scala b/samples/server/petstore/scala-play-server/app/model/Category.scala index 006c0e561dea..120411990fb3 100644 --- a/samples/server/petstore/scala-play-server/app/model/Category.scala +++ b/samples/server/petstore/scala-play-server/app/model/Category.scala @@ -5,7 +5,7 @@ import play.api.libs.json._ /** * A category for a pet */ -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") case class Category( id: Option[Long], name: Option[String] diff --git a/samples/server/petstore/scala-play-server/app/model/Order.scala b/samples/server/petstore/scala-play-server/app/model/Order.scala index b82378a3791a..c911b7f444d2 100644 --- a/samples/server/petstore/scala-play-server/app/model/Order.scala +++ b/samples/server/petstore/scala-play-server/app/model/Order.scala @@ -7,7 +7,7 @@ import java.time.OffsetDateTime * An order for a pets from the pet store * @param status Order Status */ -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") case class Order( id: Option[Long], petId: Option[Long], diff --git a/samples/server/petstore/scala-play-server/app/model/Pet.scala b/samples/server/petstore/scala-play-server/app/model/Pet.scala index 207929809288..2f50116cd436 100644 --- a/samples/server/petstore/scala-play-server/app/model/Pet.scala +++ b/samples/server/petstore/scala-play-server/app/model/Pet.scala @@ -6,7 +6,7 @@ import play.api.libs.json._ * A pet for sale in the pet store * @param status pet status in the store */ -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") case class Pet( id: Option[Long], category: Option[Category], diff --git a/samples/server/petstore/scala-play-server/app/model/Tag.scala b/samples/server/petstore/scala-play-server/app/model/Tag.scala index 2d8a1f21fcb8..4a20e2acdf08 100644 --- a/samples/server/petstore/scala-play-server/app/model/Tag.scala +++ b/samples/server/petstore/scala-play-server/app/model/Tag.scala @@ -5,7 +5,7 @@ import play.api.libs.json._ /** * A tag for a pet */ -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") case class Tag( id: Option[Long], name: Option[String] diff --git a/samples/server/petstore/scala-play-server/app/model/User.scala b/samples/server/petstore/scala-play-server/app/model/User.scala index 4d92a101a9e5..af11a3d3c934 100644 --- a/samples/server/petstore/scala-play-server/app/model/User.scala +++ b/samples/server/petstore/scala-play-server/app/model/User.scala @@ -6,7 +6,7 @@ import play.api.libs.json._ * A User who is purchasing from the pet store * @param userStatus User Status */ -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") case class User( id: Option[Long], username: Option[String], diff --git a/samples/server/petstore/scala-play-server/app/org/openapitools/Module.scala b/samples/server/petstore/scala-play-server/app/org/openapitools/Module.scala index f135171d48d1..98382284f9e9 100644 --- a/samples/server/petstore/scala-play-server/app/org/openapitools/Module.scala +++ b/samples/server/petstore/scala-play-server/app/org/openapitools/Module.scala @@ -4,7 +4,7 @@ import api._ import play.api.inject.{Binding, Module => PlayModule} import play.api.{Configuration, Environment} -@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2019-03-26T16:21:58.590+08:00[Asia/Hong_Kong]") +@javax.annotation.Generated(value = Array("org.openapitools.codegen.languages.ScalaPlayFrameworkServerCodegen"), date = "2020-01-04T23:10:22.106-05:00[America/New_York]") class Module extends PlayModule { override def bindings(environment: Environment, configuration: Configuration): Seq[Binding[_]] = Seq( bind[PetApi].to[PetApiImpl], diff --git a/samples/server/petstore/scala-play-server/public/openapi.json b/samples/server/petstore/scala-play-server/public/openapi.json index 5781506eb926..0ef21458be8d 100644 --- a/samples/server/petstore/scala-play-server/public/openapi.json +++ b/samples/server/petstore/scala-play-server/public/openapi.json @@ -1,35 +1,32 @@ { "openapi" : "3.0.1", "info" : { - "title" : "OpenAPI Petstore", "description" : "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.", "license" : { "name" : "Apache-2.0", "url" : "http://www.apache.org/licenses/LICENSE-2.0.html" }, + "title" : "OpenAPI Petstore", "version" : "1.0.0" }, "servers" : [ { "url" : "http://petstore.swagger.io/v2" } ], "tags" : [ { - "name" : "pet", - "description" : "Everything about your Pets" + "description" : "Everything about your Pets", + "name" : "pet" }, { - "name" : "store", - "description" : "Access to Petstore orders" + "description" : "Access to Petstore orders", + "name" : "store" }, { - "name" : "user", - "description" : "Operations about user" + "description" : "Operations about user", + "name" : "user" } ], "paths" : { "/pet" : { - "put" : { - "tags" : [ "pet" ], - "summary" : "Update an existing pet", - "operationId" : "updatePet", + "post" : { + "operationId" : "addPet", "requestBody" : { - "description" : "Pet object that needs to be added to the store", "content" : { "application/json" : { "schema" : { @@ -42,33 +39,25 @@ } } }, + "description" : "Pet object that needs to be added to the store", "required" : true }, "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Pet not found", - "content" : { } - }, "405" : { - "description" : "Validation exception", - "content" : { } + "content" : { }, + "description" : "Invalid input" } }, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] } ], + "summary" : "Add a new pet to the store", + "tags" : [ "pet" ], "x-codegen-request-body-name" : "body" }, - "post" : { - "tags" : [ "pet" ], - "summary" : "Add a new pet to the store", - "operationId" : "addPet", + "put" : { + "operationId" : "updatePet", "requestBody" : { - "description" : "Pet object that needs to be added to the store", "content" : { "application/json" : { "schema" : { @@ -81,146 +70,184 @@ } } }, + "description" : "Pet object that needs to be added to the store", "required" : true }, "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid ID supplied" + }, + "404" : { + "content" : { }, + "description" : "Pet not found" + }, "405" : { - "description" : "Invalid input", - "content" : { } + "content" : { }, + "description" : "Validation exception" } }, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] } ], + "summary" : "Update an existing pet", + "tags" : [ "pet" ], "x-codegen-request-body-name" : "body" } }, "/pet/findByStatus" : { "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by status", "description" : "Multiple status values can be provided with comma separated strings", "operationId" : "findPetsByStatus", "parameters" : [ { - "name" : "status", - "in" : "query", "description" : "Status values that need to be considered for filter", - "required" : true, - "style" : "form", "explode" : false, + "in" : "query", + "name" : "status", + "required" : true, "schema" : { - "type" : "array", "items" : { - "type" : "string", "default" : "available", - "enum" : [ "available", "pending", "sold" ] - } - } + "enum" : [ "available", "pending", "sold" ], + "type" : "string" + }, + "type" : "array" + }, + "style" : "form" } ], "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/Pet" - } + }, + "type" : "array" } }, "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/Pet" - } + }, + "type" : "array" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid status value", - "content" : { } + "content" : { }, + "description" : "Invalid status value" } }, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] - } ] + } ], + "summary" : "Finds Pets by status", + "tags" : [ "pet" ] } }, "/pet/findByTags" : { "get" : { - "tags" : [ "pet" ], - "summary" : "Finds Pets by tags", + "deprecated" : true, "description" : "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", "operationId" : "findPetsByTags", "parameters" : [ { - "name" : "tags", - "in" : "query", "description" : "Tags to filter by", - "required" : true, - "style" : "form", "explode" : false, + "in" : "query", + "name" : "tags", + "required" : true, "schema" : { - "type" : "array", "items" : { "type" : "string" - } - } + }, + "type" : "array" + }, + "style" : "form" } ], "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/Pet" - } + }, + "type" : "array" } }, "application/json" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/Pet" - } + }, + "type" : "array" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid tag value", - "content" : { } + "content" : { }, + "description" : "Invalid tag value" } }, - "deprecated" : true, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] - } ] + } ], + "summary" : "Finds Pets by tags", + "tags" : [ "pet" ] } }, "/pet/{petId}" : { + "delete" : { + "operationId" : "deletePet", + "parameters" : [ { + "in" : "header", + "name" : "api_key", + "schema" : { + "type" : "string" + } + }, { + "description" : "Pet id to delete", + "in" : "path", + "name" : "petId", + "required" : true, + "schema" : { + "format" : "int64", + "type" : "integer" + } + } ], + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid pet value" + } + }, + "security" : [ { + "petstore_auth" : [ "write:pets", "read:pets" ] + } ], + "summary" : "Deletes a pet", + "tags" : [ "pet" ] + }, "get" : { - "tags" : [ "pet" ], - "summary" : "Find pet by ID", "description" : "Returns a single pet", "operationId" : "getPetById", "parameters" : [ { - "name" : "petId", - "in" : "path", "description" : "ID of pet to return", + "in" : "path", + "name" : "petId", "required" : true, "schema" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" } } ], "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { @@ -232,33 +259,34 @@ "$ref" : "#/components/schemas/Pet" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid ID supplied", - "content" : { } + "content" : { }, + "description" : "Invalid ID supplied" }, "404" : { - "description" : "Pet not found", - "content" : { } + "content" : { }, + "description" : "Pet not found" } }, "security" : [ { "api_key" : [ ] - } ] + } ], + "summary" : "Find pet by ID", + "tags" : [ "pet" ] }, "post" : { - "tags" : [ "pet" ], - "summary" : "Updates a pet in the store with form data", "operationId" : "updatePetWithForm", "parameters" : [ { - "name" : "petId", - "in" : "path", "description" : "ID of pet that needs to be updated", + "in" : "path", + "name" : "petId", "required" : true, "schema" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" } } ], "requestBody" : { @@ -267,12 +295,12 @@ "schema" : { "properties" : { "name" : { - "type" : "string", - "description" : "Updated name of the pet" + "description" : "Updated name of the pet", + "type" : "string" }, "status" : { - "type" : "string", - "description" : "Updated status of the pet" + "description" : "Updated status of the pet", + "type" : "string" } } } @@ -281,58 +309,28 @@ }, "responses" : { "405" : { - "description" : "Invalid input", - "content" : { } + "content" : { }, + "description" : "Invalid input" } }, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] - } ] - }, - "delete" : { - "tags" : [ "pet" ], - "summary" : "Deletes a pet", - "operationId" : "deletePet", - "parameters" : [ { - "name" : "api_key", - "in" : "header", - "schema" : { - "type" : "string" - } - }, { - "name" : "petId", - "in" : "path", - "description" : "Pet id to delete", - "required" : true, - "schema" : { - "type" : "integer", - "format" : "int64" - } } ], - "responses" : { - "400" : { - "description" : "Invalid pet value", - "content" : { } - } - }, - "security" : [ { - "petstore_auth" : [ "write:pets", "read:pets" ] - } ] + "summary" : "Updates a pet in the store with form data", + "tags" : [ "pet" ] } }, "/pet/{petId}/uploadImage" : { "post" : { - "tags" : [ "pet" ], - "summary" : "uploads an image", "operationId" : "uploadFile", "parameters" : [ { - "name" : "petId", - "in" : "path", "description" : "ID of pet to update", + "in" : "path", + "name" : "petId", "required" : true, "schema" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" } } ], "requestBody" : { @@ -341,13 +339,13 @@ "schema" : { "properties" : { "additionalMetadata" : { - "type" : "string", - "description" : "Additional data to pass to server" + "description" : "Additional data to pass to server", + "type" : "string" }, "file" : { - "type" : "string", "description" : "file to upload", - "format" : "binary" + "format" : "binary", + "type" : "string" } } } @@ -356,55 +354,54 @@ }, "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/json" : { "schema" : { "$ref" : "#/components/schemas/ApiResponse" } } - } + }, + "description" : "successful operation" } }, "security" : [ { "petstore_auth" : [ "write:pets", "read:pets" ] - } ] + } ], + "summary" : "uploads an image", + "tags" : [ "pet" ] } }, "/store/inventory" : { "get" : { - "tags" : [ "store" ], - "summary" : "Returns pet inventories by status", "description" : "Returns a map of status codes to quantities", "operationId" : "getInventory", "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/json" : { "schema" : { - "type" : "object", "additionalProperties" : { - "type" : "integer", - "format" : "int32" - } + "format" : "int32", + "type" : "integer" + }, + "type" : "object" } } - } + }, + "description" : "successful operation" } }, "security" : [ { "api_key" : [ ] - } ] + } ], + "summary" : "Returns pet inventories by status", + "tags" : [ "store" ] } }, "/store/order" : { "post" : { - "tags" : [ "store" ], - "summary" : "Place an order for a pet", "operationId" : "placeOrder", "requestBody" : { - "description" : "order placed for purchasing the pet", "content" : { "*/*" : { "schema" : { @@ -412,11 +409,11 @@ } } }, + "description" : "order placed for purchasing the pet", "required" : true }, "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { @@ -428,37 +425,62 @@ "$ref" : "#/components/schemas/Order" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid Order", - "content" : { } + "content" : { }, + "description" : "Invalid Order" } }, + "summary" : "Place an order for a pet", + "tags" : [ "store" ], "x-codegen-request-body-name" : "body" } }, "/store/order/{orderId}" : { + "delete" : { + "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", + "operationId" : "deleteOrder", + "parameters" : [ { + "description" : "ID of the order that needs to be deleted", + "in" : "path", + "name" : "orderId", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid ID supplied" + }, + "404" : { + "content" : { }, + "description" : "Order not found" + } + }, + "summary" : "Delete purchase order by ID", + "tags" : [ "store" ] + }, "get" : { - "tags" : [ "store" ], - "summary" : "Find purchase order by ID", "description" : "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", "operationId" : "getOrderById", "parameters" : [ { - "name" : "orderId", - "in" : "path", "description" : "ID of pet that needs to be fetched", + "in" : "path", + "name" : "orderId", "required" : true, "schema" : { + "format" : "int64", "maximum" : 5, "minimum" : 1, - "type" : "integer", - "format" : "int64" + "type" : "integer" } } ], "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { @@ -470,52 +492,27 @@ "$ref" : "#/components/schemas/Order" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid ID supplied", - "content" : { } + "content" : { }, + "description" : "Invalid ID supplied" }, "404" : { - "description" : "Order not found", - "content" : { } - } - } - }, - "delete" : { - "tags" : [ "store" ], - "summary" : "Delete purchase order by ID", - "description" : "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", - "operationId" : "deleteOrder", - "parameters" : [ { - "name" : "orderId", - "in" : "path", - "description" : "ID of the order that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" + "content" : { }, + "description" : "Order not found" } - } ], - "responses" : { - "400" : { - "description" : "Invalid ID supplied", - "content" : { } - }, - "404" : { - "description" : "Order not found", - "content" : { } - } - } + }, + "summary" : "Find purchase order by ID", + "tags" : [ "store" ] } }, "/user" : { "post" : { - "tags" : [ "user" ], - "summary" : "Create user", "description" : "This can only be done by the logged in user.", "operationId" : "createUser", "requestBody" : { - "description" : "Created user object", "content" : { "*/*" : { "schema" : { @@ -523,90 +520,91 @@ } } }, + "description" : "Created user object", "required" : true }, "responses" : { "default" : { - "description" : "successful operation", - "content" : { } + "content" : { }, + "description" : "successful operation" } }, + "summary" : "Create user", + "tags" : [ "user" ], "x-codegen-request-body-name" : "body" } }, "/user/createWithArray" : { "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", "operationId" : "createUsersWithArrayInput", "requestBody" : { - "description" : "List of user object", "content" : { "*/*" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/User" - } + }, + "type" : "array" } } }, + "description" : "List of user object", "required" : true }, "responses" : { "default" : { - "description" : "successful operation", - "content" : { } + "content" : { }, + "description" : "successful operation" } }, + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ], "x-codegen-request-body-name" : "body" } }, "/user/createWithList" : { "post" : { - "tags" : [ "user" ], - "summary" : "Creates list of users with given input array", "operationId" : "createUsersWithListInput", "requestBody" : { - "description" : "List of user object", "content" : { "*/*" : { "schema" : { - "type" : "array", "items" : { "$ref" : "#/components/schemas/User" - } + }, + "type" : "array" } } }, + "description" : "List of user object", "required" : true }, "responses" : { "default" : { - "description" : "successful operation", - "content" : { } + "content" : { }, + "description" : "successful operation" } }, + "summary" : "Creates list of users with given input array", + "tags" : [ "user" ], "x-codegen-request-body-name" : "body" } }, "/user/login" : { "get" : { - "tags" : [ "user" ], - "summary" : "Logs user into the system", "operationId" : "loginUser", "parameters" : [ { - "name" : "username", - "in" : "query", "description" : "The user name for login", + "in" : "query", + "name" : "username", "required" : true, "schema" : { "type" : "string" } }, { - "name" : "password", - "in" : "query", "description" : "The password for login in clear text", + "in" : "query", + "name" : "password", "required" : true, "schema" : { "type" : "string" @@ -614,65 +612,90 @@ } ], "responses" : { "200" : { - "description" : "successful operation", - "headers" : { - "X-Rate-Limit" : { - "description" : "calls per hour allowed by the user", + "content" : { + "application/xml" : { "schema" : { - "type" : "integer", - "format" : "int32" + "type" : "string" } }, - "X-Expires-After" : { - "description" : "date in UTC when toekn expires", + "application/json" : { "schema" : { - "type" : "string", - "format" : "date-time" + "type" : "string" } } }, - "content" : { - "application/xml" : { + "description" : "successful operation", + "headers" : { + "X-Rate-Limit" : { + "description" : "calls per hour allowed by the user", "schema" : { - "type" : "string" + "format" : "int32", + "type" : "integer" } }, - "application/json" : { + "X-Expires-After" : { + "description" : "date in UTC when toekn expires", "schema" : { + "format" : "date-time", "type" : "string" } } } }, "400" : { - "description" : "Invalid username/password supplied", - "content" : { } + "content" : { }, + "description" : "Invalid username/password supplied" } - } + }, + "summary" : "Logs user into the system", + "tags" : [ "user" ] } }, "/user/logout" : { "get" : { - "tags" : [ "user" ], - "summary" : "Logs out current logged in user session", "operationId" : "logoutUser", "responses" : { "default" : { - "description" : "successful operation", - "content" : { } + "content" : { }, + "description" : "successful operation" } - } + }, + "summary" : "Logs out current logged in user session", + "tags" : [ "user" ] } }, "/user/{username}" : { + "delete" : { + "description" : "This can only be done by the logged in user.", + "operationId" : "deleteUser", + "parameters" : [ { + "description" : "The name that needs to be deleted", + "in" : "path", + "name" : "username", + "required" : true, + "schema" : { + "type" : "string" + } + } ], + "responses" : { + "400" : { + "content" : { }, + "description" : "Invalid username supplied" + }, + "404" : { + "content" : { }, + "description" : "User not found" + } + }, + "summary" : "Delete user", + "tags" : [ "user" ] + }, "get" : { - "tags" : [ "user" ], - "summary" : "Get user by user name", "operationId" : "getUserByName", "parameters" : [ { - "name" : "username", - "in" : "path", "description" : "The name that needs to be fetched. Use user1 for testing.", + "in" : "path", + "name" : "username", "required" : true, "schema" : { "type" : "string" @@ -680,7 +703,6 @@ } ], "responses" : { "200" : { - "description" : "successful operation", "content" : { "application/xml" : { "schema" : { @@ -692,34 +714,34 @@ "$ref" : "#/components/schemas/User" } } - } + }, + "description" : "successful operation" }, "400" : { - "description" : "Invalid username supplied", - "content" : { } + "content" : { }, + "description" : "Invalid username supplied" }, "404" : { - "description" : "User not found", - "content" : { } + "content" : { }, + "description" : "User not found" } - } + }, + "summary" : "Get user by user name", + "tags" : [ "user" ] }, "put" : { - "tags" : [ "user" ], - "summary" : "Updated user", "description" : "This can only be done by the logged in user.", "operationId" : "updateUser", "parameters" : [ { - "name" : "username", - "in" : "path", "description" : "name that need to be deleted", + "in" : "path", + "name" : "username", "required" : true, "schema" : { "type" : "string" } } ], "requestBody" : { - "description" : "Updated user object", "content" : { "*/*" : { "schema" : { @@ -727,120 +749,107 @@ } } }, + "description" : "Updated user object", "required" : true }, "responses" : { "400" : { - "description" : "Invalid user supplied", - "content" : { } + "content" : { }, + "description" : "Invalid user supplied" }, "404" : { - "description" : "User not found", - "content" : { } + "content" : { }, + "description" : "User not found" } }, - "x-codegen-request-body-name" : "body" - }, - "delete" : { + "summary" : "Updated user", "tags" : [ "user" ], - "summary" : "Delete user", - "description" : "This can only be done by the logged in user.", - "operationId" : "deleteUser", - "parameters" : [ { - "name" : "username", - "in" : "path", - "description" : "The name that needs to be deleted", - "required" : true, - "schema" : { - "type" : "string" - } - } ], - "responses" : { - "400" : { - "description" : "Invalid username supplied", - "content" : { } - }, - "404" : { - "description" : "User not found", - "content" : { } - } - } + "x-codegen-request-body-name" : "body" } } }, "components" : { "schemas" : { "Order" : { - "title" : "Pet Order", - "type" : "object", + "description" : "An order for a pets from the pet store", + "example" : { + "petId" : 6, + "quantity" : 1, + "id" : 0, + "shipDate" : "2000-01-23T04:56:07.000+00:00", + "complete" : false, + "status" : "placed" + }, "properties" : { "id" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "petId" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "quantity" : { - "type" : "integer", - "format" : "int32" + "format" : "int32", + "type" : "integer" }, "shipDate" : { - "type" : "string", - "format" : "date-time" + "format" : "date-time", + "type" : "string" }, "status" : { - "type" : "string", "description" : "Order Status", - "enum" : [ "placed", "approved", "delivered" ] + "enum" : [ "placed", "approved", "delivered" ], + "type" : "string" }, "complete" : { - "type" : "boolean", - "default" : false + "default" : false, + "type" : "boolean" } }, - "description" : "An order for a pets from the pet store", - "example" : { - "petId" : 6, - "quantity" : 1, - "id" : 0, - "shipDate" : "2000-01-23T04:56:07.000+00:00", - "complete" : false, - "status" : "placed" - }, + "title" : "Pet Order", + "type" : "object", "xml" : { "name" : "Order" } }, "Category" : { - "title" : "Pet category", - "type" : "object", + "description" : "A category for a pet", + "example" : { + "name" : "name", + "id" : 6 + }, "properties" : { "id" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "name" : { "type" : "string" } }, - "description" : "A category for a pet", - "example" : { - "name" : "name", - "id" : 6 - }, + "title" : "Pet category", + "type" : "object", "xml" : { "name" : "Category" } }, "User" : { - "title" : "a User", - "type" : "object", + "description" : "A User who is purchasing from the pet store", + "example" : { + "firstName" : "firstName", + "lastName" : "lastName", + "password" : "password", + "userStatus" : 6, + "phone" : "phone", + "id" : 0, + "email" : "email", + "username" : "username" + }, "properties" : { "id" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "username" : { "type" : "string" @@ -861,118 +870,113 @@ "type" : "string" }, "userStatus" : { - "type" : "integer", "description" : "User Status", - "format" : "int32" + "format" : "int32", + "type" : "integer" } }, - "description" : "A User who is purchasing from the pet store", - "example" : { - "firstName" : "firstName", - "lastName" : "lastName", - "password" : "password", - "userStatus" : 6, - "phone" : "phone", - "id" : 0, - "email" : "email", - "username" : "username" - }, + "title" : "a User", + "type" : "object", "xml" : { "name" : "User" } }, "Tag" : { - "title" : "Pet Tag", - "type" : "object", + "description" : "A tag for a pet", + "example" : { + "name" : "name", + "id" : 1 + }, "properties" : { "id" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "name" : { "type" : "string" } }, - "description" : "A tag for a pet", - "example" : { - "name" : "name", - "id" : 1 - }, + "title" : "Pet Tag", + "type" : "object", "xml" : { "name" : "Tag" } }, "Pet" : { - "title" : "a Pet", - "required" : [ "name", "photoUrls" ], - "type" : "object", + "description" : "A pet for sale in the pet store", + "example" : { + "photoUrls" : [ "photoUrls", "photoUrls" ], + "name" : "doggie", + "id" : 0, + "category" : { + "name" : "name", + "id" : 6 + }, + "tags" : [ { + "name" : "name", + "id" : 1 + }, { + "name" : "name", + "id" : 1 + } ], + "status" : "available" + }, "properties" : { "id" : { - "type" : "integer", - "format" : "int64" + "format" : "int64", + "type" : "integer" }, "category" : { "$ref" : "#/components/schemas/Category" }, "name" : { - "type" : "string", - "example" : "doggie" + "example" : "doggie", + "type" : "string" }, "photoUrls" : { + "items" : { + "type" : "string" + }, "type" : "array", "xml" : { "name" : "photoUrl", "wrapped" : true - }, - "items" : { - "type" : "string" } }, "tags" : { + "items" : { + "$ref" : "#/components/schemas/Tag" + }, "type" : "array", "xml" : { "name" : "tag", "wrapped" : true - }, - "items" : { - "$ref" : "#/components/schemas/Tag" } }, "status" : { - "type" : "string", "description" : "pet status in the store", - "enum" : [ "available", "pending", "sold" ] + "enum" : [ "available", "pending", "sold" ], + "type" : "string" } }, - "description" : "A pet for sale in the pet store", - "example" : { - "photoUrls" : [ "photoUrls", "photoUrls" ], - "name" : "doggie", - "id" : 0, - "category" : { - "name" : "name", - "id" : 6 - }, - "tags" : [ { - "name" : "name", - "id" : 1 - }, { - "name" : "name", - "id" : 1 - } ], - "status" : "available" - }, + "required" : [ "name", "photoUrls" ], + "title" : "a Pet", + "type" : "object", "xml" : { "name" : "Pet" } }, "ApiResponse" : { - "title" : "An uploaded response", - "type" : "object", + "description" : "Describes the result of uploading an image resource", + "example" : { + "code" : 0, + "type" : "type", + "message" : "message" + }, "properties" : { "code" : { - "type" : "integer", - "format" : "int32" + "format" : "int32", + "type" : "integer" }, "type" : { "type" : "string" @@ -981,17 +985,12 @@ "type" : "string" } }, - "description" : "Describes the result of uploading an image resource", - "example" : { - "code" : 0, - "type" : "type", - "message" : "message" - } + "title" : "An uploaded response", + "type" : "object" } }, "securitySchemes" : { "petstore_auth" : { - "type" : "oauth2", "flows" : { "implicit" : { "authorizationUrl" : "http://petstore.swagger.io/api/oauth/dialog", @@ -1000,12 +999,13 @@ "read:pets" : "read your pets" } } - } + }, + "type" : "oauth2" }, "api_key" : { - "type" : "apiKey", + "in" : "header", "name" : "api_key", - "in" : "header" + "type" : "apiKey" } } } From d8b9b74e7a4a8ef31c3815fe75bc614312a9ccba Mon Sep 17 00:00:00 2001 From: Jim Schubert Date: Sun, 5 Jan 2020 00:51:26 -0500 Subject: [PATCH 5/5] Update ScalaPlayFrameworkServerCodegen.java Scala Play defaulted to List and should continue to do so. --- .../codegen/languages/ScalaPlayFrameworkServerCodegen.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 b2453760a732..22bcbf8f61cb 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 @@ -69,7 +69,7 @@ public ScalaPlayFrameworkServerCodegen() { modelPackage = "model"; instantiationTypes.put("map", "Map"); - instantiationTypes.put("array", "ListBuffer"); + instantiationTypes.put("array", "List"); typeMapping.put("DateTime", "OffsetDateTime"); typeMapping.put("Date", "LocalDate");