Skip to content

Commit

Permalink
Merge branch 'master' into ensures
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
jimschubert committed Jun 6, 2020
2 parents 4e5e81b + 835dab4 commit 9ddc45c
Show file tree
Hide file tree
Showing 778 changed files with 7,520 additions and 3,159 deletions.
2 changes: 1 addition & 1 deletion appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ install:
- git clone https://github.com/wing328/swagger-samples
- 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"
- ps: $PSVersionTable.PSVersion
- ps: Install-Module Pester -Force -Scope CurrentUser -RequiredVersion 4.3.1
- ps: Install-Module Pester -Force -Scope CurrentUser
build_script:
- dotnet --info
# build C# API client (netcore)
Expand Down
2 changes: 1 addition & 1 deletion docs/installation.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ npm install @openapitools/openapi-generator-cli -D
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:

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

> `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.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5594,9 +5594,9 @@ protected String getCollectionFormat(Parameter parameter) {
} else if (Parameter.StyleEnum.SIMPLE.equals(parameter.getStyle())) {
return "csv";
} else if (Parameter.StyleEnum.PIPEDELIMITED.equals(parameter.getStyle())) {
return "pipe";
return "pipes";
} else if (Parameter.StyleEnum.SPACEDELIMITED.equals(parameter.getStyle())) {
return "space";
return "ssv";
} else {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import java.io.File;
import java.util.*;

import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.underscore;

Expand Down Expand Up @@ -94,7 +93,7 @@ public AbstractGoCodegen() {
"byte",
"map[string]interface{}",
"interface{}"
)
)
);

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

if ("AdditionalProperties".equals(name)) {
// AdditionalProperties is a reserved field (additionalProperties: true), use AdditionalPropertiesField instead
return "AdditionalPropertiesField";
}

return name;
}

Expand Down Expand Up @@ -320,7 +324,7 @@ public String toApiFilename(String name) {

/**
* Return the golang implementation type for the specified property.
*
*
* @param p the OAS property.
* @return the golang implementation type.
*/
Expand Down Expand Up @@ -378,7 +382,7 @@ public String getTypeDeclaration(Schema p) {

/**
* Return the OpenAPI type for the property.
*
*
* @param p the OAS property.
* @return the OpenAPI type.
*/
Expand All @@ -404,20 +408,19 @@ public String getSchemaType(Schema p) {

/**
* Determines the golang instantiation type of the specified schema.
*
* <p>
* This function is called when the input schema is a map, and specifically
* when the 'additionalProperties' attribute is present in the OAS specification.
* Codegen invokes this function to resolve the "parent" association to
* 'additionalProperties'.
*
* <p>
* Note the 'parent' attribute in the codegen model is used in the following scenarios:
* - Indicate a polymorphic association with some other type (e.g. class inheritance).
* - If the specification has a discriminator, cogegen create a “parent” based on the discriminator.
* - Use of the 'additionalProperties' attribute in the OAS specification.
* This is the specific scenario when codegen invokes this function.
* This is the specific scenario when codegen invokes this function.
*
* @param property the input schema
*
* @return the golang instantiation type of the specified property.
*/
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
package org.openapitools.codegen.languages;

import com.google.common.base.Strings;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
Expand All @@ -44,7 +43,6 @@
import java.util.*;
import java.util.regex.Pattern;

import static org.openapitools.codegen.utils.OnceLogger.once;
import static org.openapitools.codegen.utils.StringUtils.*;

public abstract class AbstractJavaCodegen extends DefaultCodegen implements CodegenConfig {
Expand Down Expand Up @@ -865,12 +863,12 @@ public String toDefaultValue(Schema schema) {
Date date = (Date) schema.getDefault();
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
return String.format(Locale.ROOT, localDate.toString(), "");
} else if (schema.getDefault() instanceof OffsetDateTime){
OffsetDateTime date = (OffsetDateTime) schema.getDefault();
return date.format(DateTimeFormatter.ISO_DATE_TIME);
} else if (schema.getDefault() instanceof java.time.OffsetDateTime) {
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()))";
} else {
_default = (String) schema.getDefault();
}

if (schema.getEnum() == null) {
return "\"" + escapeText(_default) + "\"";
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -497,13 +497,20 @@ public String toVarName(String name) {
name = name.toLowerCase(Locale.ROOT);
}

//Unreal variable names are CamelCase
String camelCaseName = camelize(name, false);

//Avoid empty variable name at all costs
if(!camelCaseName.isEmpty()) {
name = camelCaseName;
}

// for reserved word or word starting with number, append _
if (isReservedWord(name) || name.matches("^\\d.*")) {
name = escapeReservedWord(name);
}

//Unreal variable names are CamelCase
return camelize(name, false);

return name;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,9 +222,12 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
if (model.anyOf != null && !model.anyOf.isEmpty()) {
imports.add(createMapping("import", "fmt"));
}
}


// add x-additional-properties
if ("map[string]map[string]interface{}".equals(model.parent)) {
model.vendorExtensions.put("x-additional-properties", true);
}
}
}
return objs;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -922,6 +922,31 @@ public Map<String, Object> postProcessModels(Map<String, Object> objs) {
model.anyOf.remove("ModelNull");
}

// add vendor extension for additonalProperties: true
if ("null<String, SystemCollectionsHashtable>".equals(model.parent)) {
model.vendorExtensions.put("x-additional-properties", true);
}

// automatically create discriminator mapping for oneOf/anyOf if not present
if (((model.oneOf != null && !model.oneOf.isEmpty()) || (model.anyOf != null && !model.anyOf.isEmpty())) &&
model.discriminator != null && model.discriminator.getMapping() == null) {
// create mappedModels
Set<String> schemas = new HashSet<>();
if (model.oneOf != null && !model.oneOf.isEmpty()) {
schemas = model.oneOf;
} else if (model.anyOf != null && !model.anyOf.isEmpty()) {
schemas = model.anyOf;
}

HashSet<CodegenDiscriminator.MappedModel> mappedModels = new HashSet<>();

for (String s: schemas) {
mappedModels.add(new CodegenDiscriminator.MappedModel(s, s));
}

model.discriminator.setMappedModels(mappedModels);

}
}

return objs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,14 +421,12 @@ public Map<String, Object> postProcessAllModels(Map<String, Object> objs) {

Schema modelSchema = ModelUtils.getSchema(this.openAPI, cm.name);
CodegenProperty modelProperty = fromProperty("value", modelSchema);

if (cm.isEnum || cm.isAlias) {
if (!modelProperty.isEnum && !modelProperty.hasValidation) {
if (!modelProperty.isEnum && !modelProperty.hasValidation && !cm.isArrayModel) {
// remove these models because they are aliases and do not have any enums or validations
modelSchemasToRemove.put(cm.name, modelSchema);
}
} else if (cm.isArrayModel && !modelProperty.isEnum && !modelProperty.hasValidation) {
// remove any ArrayModels which lack validation and enums
modelSchemasToRemove.put(cm.name, modelSchema);
}
}
}
Expand Down Expand Up @@ -829,10 +827,10 @@ public CodegenModel fromModel(String name, Schema schema) {
result.unescapedDescription = simpleModelName(name);

// make non-object type models have one property so we can use it to store enums and validations
if (result.isAlias || result.isEnum) {
if (result.isAlias || result.isEnum || result.isArrayModel) {
Schema modelSchema = ModelUtils.getSchema(this.openAPI, result.name);
CodegenProperty modelProperty = fromProperty("value", modelSchema);
if (modelProperty.isEnum == true || modelProperty.hasValidation == true) {
if (modelProperty.isEnum == true || modelProperty.hasValidation == true || result.isArrayModel) {
// these models are non-object models with enums and/or validations
// add a single property to the model so we can have a way to access validations
result.isAlias = true;
Expand All @@ -847,7 +845,6 @@ public CodegenModel fromModel(String name, Schema schema) {
postProcessModelProperty(result, prop);
}
}

}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,9 @@ void {{classname}}::{{operationIdSnakeCase}}_handler(const Pistache::Rest::Reque
//send a 400 error
response.send(Pistache::Http::Code::Bad_Request, e.what());
return;
} catch (Pistache::Http::HttpError &e) {
response.send(static_cast<Pistache::Http::Code>(e.code()), e.what());
return;
} catch (std::exception &e) {
//send a 500 error
response.send(Pistache::Http::Code::Internal_Server_Error, e.what());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,6 @@ public class {{unrealModuleName}} : ModuleRules
"Json",
}
);
PCHUsage = PCHUsageMode.NoPCHs;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ public:
{{#responses.0}}
void SetHttpResponseCode(EHttpResponseCodes::Type InHttpResponseCode) final;
{{/responses.0}}
bool FromJson(const TSharedPtr<FJsonValue>& JsonObject) final;
bool FromJson(const TSharedPtr<FJsonValue>& JsonValue) final;

{{#returnType}}{{{returnType}}} Content;{{/returnType}}
};
Expand Down
Loading

0 comments on commit 9ddc45c

Please sign in to comment.