Skip to content

Commit 9ddc45c

Browse files
committed
Merge branch 'master' into ensures
* master: Fix typescript generator for parameter collectionFormat for pipes ssv (#6553) [C++][Pistache] Catch HttpError from user-provided handler (#6520) remove scala related profile from the pom (#6554) move ruby tests to travis (#6555) [Java][jersey2] fix cast error for default value in DateTimeOffset object (#6547) [Swift] fix GET request with array parameter (#6549) [kotlin][spring] Fix ApiUtil compilation (#6084) update python samples [Python] Fixed docstrings in api.mustache (#6391) [BUG][python] Support named arrays (#6493) [Go] whitelist AdditionalProperties in the field name (#6543) [kotlin][client] remove tabs usage (#6526) [PS] automatically derive discriminator mapping for oneOf/anyOf (#6542) [C++][Ue4] various bus fixes (#6539) Fix incorrect npx command (#6537) update pester to 5.x (#6536) comment out openapi3 java jersey2-java8 tests add additional properties support to powershell client generator (#6528) [Go][Experimental] Support additionalProperties (#6525) #5476 [kotlin] [spring] fix swagger and spring annotation for defaultValue (#6101)
2 parents 4e5e81b + 835dab4 commit 9ddc45c

File tree

778 files changed

+7520
-3159
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

778 files changed

+7520
-3159
lines changed

appveyor.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ install:
3232
- git clone https://github.com/wing328/swagger-samples
3333
- ps: Start-Process -FilePath 'C:\maven\apache-maven-3.2.5\bin\mvn' -ArgumentList 'jetty:run' -WorkingDirectory "$env:appveyor_build_folder\swagger-samples\java\java-jersey-jaxrs-ci"
3434
- ps: $PSVersionTable.PSVersion
35-
- ps: Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 4.3.1
35+
- ps: Install-Module Pester -Force -Scope CurrentUser
3636
build_script:
3737
- dotnet --info
3838
# build C# API client (netcore)

docs/installation.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ npm install @openapitools/openapi-generator-cli -D
3333
Then, **generate** a ruby client from a valid [petstore.yaml](https://raw.githubusercontent.com/openapitools/openapi-generator/master/modules/openapi-generator/src/test/resources/2_0/petstore.yaml) doc:
3434

3535
```bash
36-
npx openapi-generator generate -i petstore.yaml -g ruby -o /tmp/test/
36+
npx @openapitools/openapi-generator-cli generate -i petstore.yaml -g ruby -o /tmp/test/
3737
```
3838

3939
> `npx` will execute a globally available `openapi-generator`, and if not found it will fall back to project-local commands. The result is that the above command will work regardless of which installation method you've chosen.

modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultCodegen.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -5594,9 +5594,9 @@ protected String getCollectionFormat(Parameter parameter) {
55945594
} else if (Parameter.StyleEnum.SIMPLE.equals(parameter.getStyle())) {
55955595
return "csv";
55965596
} else if (Parameter.StyleEnum.PIPEDELIMITED.equals(parameter.getStyle())) {
5597-
return "pipe";
5597+
return "pipes";
55985598
} else if (Parameter.StyleEnum.SPACEDELIMITED.equals(parameter.getStyle())) {
5599-
return "space";
5599+
return "ssv";
56005600
} else {
56015601
return null;
56025602
}

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractGoCodegen.java

+11-8
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
import java.io.File;
3030
import java.util.*;
3131

32-
import static org.openapitools.codegen.utils.OnceLogger.once;
3332
import static org.openapitools.codegen.utils.StringUtils.camelize;
3433
import static org.openapitools.codegen.utils.StringUtils.underscore;
3534

@@ -94,7 +93,7 @@ public AbstractGoCodegen() {
9493
"byte",
9594
"map[string]interface{}",
9695
"interface{}"
97-
)
96+
)
9897
);
9998

10099
instantiationTypes.clear();
@@ -210,6 +209,11 @@ public String toVarName(String name) {
210209
if (name.matches("^\\d.*"))
211210
name = "Var" + name;
212211

212+
if ("AdditionalProperties".equals(name)) {
213+
// AdditionalProperties is a reserved field (additionalProperties: true), use AdditionalPropertiesField instead
214+
return "AdditionalPropertiesField";
215+
}
216+
213217
return name;
214218
}
215219

@@ -320,7 +324,7 @@ public String toApiFilename(String name) {
320324

321325
/**
322326
* Return the golang implementation type for the specified property.
323-
*
327+
*
324328
* @param p the OAS property.
325329
* @return the golang implementation type.
326330
*/
@@ -378,7 +382,7 @@ public String getTypeDeclaration(Schema p) {
378382

379383
/**
380384
* Return the OpenAPI type for the property.
381-
*
385+
*
382386
* @param p the OAS property.
383387
* @return the OpenAPI type.
384388
*/
@@ -404,20 +408,19 @@ public String getSchemaType(Schema p) {
404408

405409
/**
406410
* Determines the golang instantiation type of the specified schema.
407-
*
411+
* <p>
408412
* This function is called when the input schema is a map, and specifically
409413
* when the 'additionalProperties' attribute is present in the OAS specification.
410414
* Codegen invokes this function to resolve the "parent" association to
411415
* 'additionalProperties'.
412-
*
416+
* <p>
413417
* Note the 'parent' attribute in the codegen model is used in the following scenarios:
414418
* - Indicate a polymorphic association with some other type (e.g. class inheritance).
415419
* - If the specification has a discriminator, cogegen create a “parent” based on the discriminator.
416420
* - Use of the 'additionalProperties' attribute in the OAS specification.
417-
* This is the specific scenario when codegen invokes this function.
421+
* This is the specific scenario when codegen invokes this function.
418422
*
419423
* @param property the input schema
420-
*
421424
* @return the golang instantiation type of the specified property.
422425
*/
423426
@Override

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/AbstractJavaCodegen.java

+3-5
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
package org.openapitools.codegen.languages;
1919

2020
import com.google.common.base.Strings;
21-
2221
import io.swagger.v3.oas.models.OpenAPI;
2322
import io.swagger.v3.oas.models.Operation;
2423
import io.swagger.v3.oas.models.PathItem;
@@ -44,7 +43,6 @@
4443
import java.util.*;
4544
import java.util.regex.Pattern;
4645

47-
import static org.openapitools.codegen.utils.OnceLogger.once;
4846
import static org.openapitools.codegen.utils.StringUtils.*;
4947

5048
public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig {
@@ -865,12 +863,12 @@ public String toDefaultValue(Schema schema) {
865863
Date date = (Date) schema.getDefault();
866864
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
867865
return String.format(Locale.ROOT, localDate.toString(), "");
868-
} else if (schema.getDefault() instanceof OffsetDateTime){
869-
OffsetDateTime date = (OffsetDateTime) schema.getDefault();
870-
return date.format(DateTimeFormatter.ISO_DATE_TIME);
866+
} else if (schema.getDefault() instanceof java.time.OffsetDateTime) {
867+
return "OffsetDateTime.parse(\"" + String.format(Locale.ROOT, ((java.time.OffsetDateTime) schema.getDefault()).atZoneSameInstant(ZoneId.systemDefault()).toString(), "") + "\", java.time.format.DateTimeFormatter.ISO_ZONED_DATE_TIME.withZone(java.time.ZoneId.systemDefault()))";
871868
} else {
872869
_default = (String) schema.getDefault();
873870
}
871+
874872
if (schema.getEnum() == null) {
875873
return "\"" + escapeText(_default) + "\"";
876874
} else {

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/CppUE4ClientCodegen.java

+10-3
Original file line numberDiff line numberDiff line change
@@ -497,13 +497,20 @@ public String toVarName(String name) {
497497
name = name.toLowerCase(Locale.ROOT);
498498
}
499499

500+
//Unreal variable names are CamelCase
501+
String camelCaseName = camelize(name, false);
502+
503+
//Avoid empty variable name at all costs
504+
if(!camelCaseName.isEmpty()) {
505+
name = camelCaseName;
506+
}
507+
500508
// for reserved word or word starting with number, append _
501509
if (isReservedWord(name) || name.matches("^\\d.*")) {
502510
name = escapeReservedWord(name);
503511
}
504-
505-
//Unreal variable names are CamelCase
506-
return camelize(name, false);
512+
513+
return name;
507514
}
508515

509516
@Override

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/GoClientExperimentalCodegen.java

+5-2
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,12 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
222222
if (model.anyOf != null && !model.anyOf.isEmpty()) {
223223
imports.add(createMapping("import", "fmt"));
224224
}
225-
}
226-
227225

226+
// add x-additional-properties
227+
if ("map[string]map[string]interface{}".equals(model.parent)) {
228+
model.vendorExtensions.put("x-additional-properties", true);
229+
}
230+
}
228231
}
229232
return objs;
230233
}

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PowerShellClientCodegen.java

+25
Original file line numberDiff line numberDiff line change
@@ -922,6 +922,31 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
922922
model.anyOf.remove("ModelNull");
923923
}
924924

925+
// add vendor extension for additonalProperties: true
926+
if ("null<String, SystemCollectionsHashtable>".equals(model.parent)) {
927+
model.vendorExtensions.put("x-additional-properties", true);
928+
}
929+
930+
// automatically create discriminator mapping for oneOf/anyOf if not present
931+
if (((model.oneOf != null && !model.oneOf.isEmpty()) || (model.anyOf != null && !model.anyOf.isEmpty())) &&
932+
model.discriminator != null && model.discriminator.getMapping() == null) {
933+
// create mappedModels
934+
Set<String> schemas = new HashSet<>();
935+
if (model.oneOf != null && !model.oneOf.isEmpty()) {
936+
schemas = model.oneOf;
937+
} else if (model.anyOf != null && !model.anyOf.isEmpty()) {
938+
schemas = model.anyOf;
939+
}
940+
941+
HashSet<CodegenDiscriminator.MappedModel> mappedModels = new HashSet<>();
942+
943+
for (String s: schemas) {
944+
mappedModels.add(new CodegenDiscriminator.MappedModel(s, s));
945+
}
946+
947+
model.discriminator.setMappedModels(mappedModels);
948+
949+
}
925950
}
926951

927952
return objs;

modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/PythonClientExperimentalCodegen.java

+4-7
Original file line numberDiff line numberDiff line change
@@ -421,14 +421,12 @@ public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {
421421

422422
Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name);
423423
CodegenProperty modelProperty = fromProperty("value", modelSchema);
424+
424425
if (cm.isEnum || cm.isAlias) {
425-
if (!modelProperty.isEnum && !modelProperty.hasValidation) {
426+
if (!modelProperty.isEnum && !modelProperty.hasValidation && !cm.isArrayModel) {
426427
// remove these models because they are aliases and do not have any enums or validations
427428
modelSchemasToRemove.put(cm.name, modelSchema);
428429
}
429-
} else if (cm.isArrayModel && !modelProperty.isEnum && !modelProperty.hasValidation) {
430-
// remove any ArrayModels which lack validation and enums
431-
modelSchemasToRemove.put(cm.name, modelSchema);
432430
}
433431
}
434432
}
@@ -829,10 +827,10 @@ public CodegenModel fromModel(String name, Schema schema) {
829827
result.unescapedDescription = simpleModelName(name);
830828

831829
// make non-object type models have one property so we can use it to store enums and validations
832-
if (result.isAlias || result.isEnum) {
830+
if (result.isAlias || result.isEnum || result.isArrayModel) {
833831
Schema modelSchema = ModelUtils.getSchema(this.openAPI, result.name);
834832
CodegenProperty modelProperty = fromProperty("value", modelSchema);
835-
if (modelProperty.isEnum == true || modelProperty.hasValidation == true) {
833+
if (modelProperty.isEnum == true || modelProperty.hasValidation == true || result.isArrayModel) {
836834
// these models are non-object models with enums and/or validations
837835
// add a single property to the model so we can have a way to access validations
838836
result.isAlias = true;
@@ -847,7 +845,6 @@ public CodegenModel fromModel(String name, Schema schema) {
847845
postProcessModelProperty(result, prop);
848846
}
849847
}
850-
851848
}
852849
}
853850

modules/openapi-generator/src/main/resources/cpp-pistache-server/api-source.mustache

+3
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ void {{classname}}::{{operationIdSnakeCase}}_handler(const Pistache::Rest::Reque
8888
//send a 400 error
8989
response.send(Pistache::Http::Code::Bad_Request, e.what());
9090
return;
91+
} catch (Pistache::Http::HttpError &e) {
92+
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
93+
return;
9194
} catch (std::exception &e) {
9295
//send a 500 error
9396
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());

modules/openapi-generator/src/main/resources/cpp-ue4/Build.cs.mustache

+1
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@ public class {{unrealModuleName}} : ModuleRules
1515
"Json",
1616
}
1717
);
18+
PCHUsage = PCHUsageMode.NoPCHs;
1819
}
1920
}

modules/openapi-generator/src/main/resources/cpp-ue4/api-operations-header.mustache

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ public:
5252
{{#responses.0}}
5353
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
5454
{{/responses.0}}
55-
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
55+
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;
5656

5757
{{#returnType}}{{{returnType}}} Content;{{/returnType}}
5858
};

0 commit comments

Comments
 (0)