Compare commits

...

9 Commits

Author SHA1 Message Date
William Cheng
b3146c9983 update version (#2591) 2019-04-04 20:50:50 +08:00
Thibault Duperron
b7b68ce0bc Change default inline object name (#2569)
* Change default inline object name

For #2516

* PR Review

* throughout
2019-04-04 12:17:03 +08:00
Jérémie Bresson
d42b6d987a Update TestNG version (#2582) 2019-04-03 10:32:54 +02:00
Thibaud Sowa
0889b8ec13 Support OAuth without 'expires_in' data (#2563)
[Java][Feign] Support OAuth without 'expires_in' data
2019-04-02 17:43:56 +08:00
Akihito Nakano
887b02c818 Add ZOZO Technologies (#2573) 2019-04-02 16:08:52 +08:00
koki
5a34f8428c Add link to the article "OpenAPI3を使ってみよう!Go言語でクライアントとスタブの自動生成まで!" (#2572) 2019-04-02 15:44:48 +09:00
Jim Schubert
128da8e84b [aspnetcore] Feature/cleanup (contributor rebase) (#2506)
* Add optValue to CliOption
* Fix compilation with ASP.Net Core 2.1
* Add ASP.Net core 2.2
* Use CliOption for classModifier, operationModifier, buildTarget, add ASP.Net core 2.2
* Make abstract method look cleaner
* Update docs
* Regenerate sample
2019-04-01 21:07:35 -04:00
Esteban Marin
ec42aca438 #2503: fix out-of-memory issue with nested objects with arrays with maxItems set by limiting to max. 5 example items (#2536) 2019-04-01 14:01:09 -04:00
William Cheng
b55cdfbe53 remove emitDefaultValue option (#2559) 2019-04-01 08:41:27 -04:00
55 changed files with 848 additions and 882 deletions

View File

@@ -555,7 +555,7 @@ Here are some companies/projects (alphabetical order) using OpenAPI Generator in
- 2019-03-07 - [OpenAPI Generator で Spring Boot と Angular をタイプセーフに繋ぐ](https://qiita.com/chibato/items/e4a748db12409b40c02f) by [Tomofumi Chiba](https://github.com/chibat)
- 2019-03-25 - [Access any REST service with the SAP S/4HANA Cloud SDK](https://blogs.sap.com/2019/03/25/integrate-sap-s4hana-cloud-sdk-with-open-api/) by [Alexander Duemont](https://people.sap.com/alexander.duemont)
- 2019-03-25 - [OpenAPI generatorを試してみる](https://qiita.com/amuyikam/items/e8a45daae59c68be0fc8) by [@amuyikam](https://twitter.com/amuyikam)
- 2019-03-27 - [OpenAPI3を使ってみようGo言語でクライアントとスタブの自動生成まで](https://techblog.zozo.com/entry/openapi3/go) by [@gold_kou](https://twitter.com/gold_kou)
## [6 - About Us](#table-of-contents)

View File

@@ -16,13 +16,14 @@ sidebar_label: aspnetcore
|packageVersion|C# package version.| |1.0.0|
|packageGuid|The GUID that will be associated with the C# project| |null|
|sourceFolder|source folder for generated code| |src|
|aspnetCoreVersion|ASP.NET Core version: 2.1 (default), 2.0 (deprecated)| |2.1|
|compatibilityVersion|ASP.Net Core CompatibilityVersion| |Version_2_1|
|aspnetCoreVersion|ASP.NET Core version: 2.2 (default), 2.1, 2.0 (deprecated)| |2.2|
|sortParamsByRequiredFlag|Sort method arguments to place required parameters before optional parameters.| |true|
|useDateTimeOffset|Use DateTimeOffset to model date-time properties| |false|
|useCollection|Deserialize array types to Collection<T> instead of List<T>.| |false|
|returnICollection|Return ICollection<T> instead of the concrete type.| |false|
|useSwashbuckle|Uses the Swashbuckle.AspNetCore NuGet package for documentation.| |true|
|classModifier|Class modifiers such as abstract or partial| ||
|operationModifier|Operation modifiers such as virtual or abstract.| |virtual|
|classModifier|Class Modifier can be empty, abstract| ||
|operationModifier|Operation Modifier can be virtual, abstract or partial| |virtual|
|buildTarget|Target to build an application or library| |program|
|generateBody|Generates method body.| |true|
|buildTarget|Target the build for a program or library.| |program|

View File

@@ -22,7 +22,6 @@ sidebar_label: csharp-netcore
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true|
|optionalProjectFile|Generate {PackageName}.csproj.| |true|
|optionalEmitDefaultValues|Set DataMember's EmitDefaultValue.| |false|
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|
|netCoreProjectFile|Use the new format (.NET Core) for .NET project files (.csproj).| |false|

View File

@@ -22,7 +22,6 @@ sidebar_label: csharp
|optionalMethodArgument|C# Optional method argument, e.g. void square(int x=10) (.net 4.0+ only).| |true|
|optionalAssemblyInfo|Generate AssemblyInfo.cs.| |true|
|optionalProjectFile|Generate {PackageName}.csproj.| |true|
|optionalEmitDefaultValues|Set DataMember's EmitDefaultValue.| |false|
|generatePropertyChanged|Specifies a AssemblyDescription for the .NET Framework global assembly attributes stored in the AssemblyInfo file.| |false|
|nonPublicApi|Generates code with reduced access modifiers; allows embedding elsewhere without exposing non-public API calls to consumers.| |false|
|allowUnicodeIdentifiers|boolean, toggles whether unicode identifiers are allowed in names or not, default is false| |false|

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.0-beta3</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -1,4 +1,4 @@
openApiGeneratorVersion=4.0.0-SNAPSHOT
openApiGeneratorVersion=4.0.0-beta3
# BEGIN placeholders
# these are just placeholders to allow contributors to build directly

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.0-beta3</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -4,7 +4,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.0-beta3</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>openapi-generator-maven-plugin</artifactId>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.0-beta3</version>
<relativePath>../..</relativePath>
</parent>
<artifactId>openapi-generator-online</artifactId>

View File

@@ -3,7 +3,7 @@
<parent>
<groupId>org.openapitools</groupId>
<artifactId>openapi-generator-project</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.0-beta3</version>
<relativePath>../..</relativePath>
</parent>
<modelVersion>4.0.0</modelVersion>

View File

@@ -28,6 +28,7 @@ public class CliOption {
private String description;
private String type;
private String defaultValue;
private String optValue;
private Map<String, String> enumValues;
public CliOption(String opt, String description) {
@@ -73,6 +74,18 @@ public class CliOption {
return this;
}
public String getOptValue() {
return this.optValue;
}
public void setOptValue(String optValue) {
if (this.enumValues!=null && this.enumValues.containsKey(optValue)) {
this.optValue = optValue;
} else {
this.optValue = null;
}
}
public CliOption addEnum(String value, String description) {
if (this.enumValues == null) {
this.enumValues = new LinkedHashMap<String, String>();

View File

@@ -191,9 +191,6 @@ public class CodegenConstants {
public static final String MODEL_NAME_SUFFIX = "modelNameSuffix";
public static final String MODEL_NAME_SUFFIX_DESC = "Suffix that will be appended to all model names. Default is the empty string.";
public static final String OPTIONAL_EMIT_DEFAULT_VALUES = "optionalEmitDefaultValues";
public static final String OPTIONAL_EMIT_DEFAULT_VALUES_DESC = "Set DataMember's EmitDefaultValue.";
public static final String GIT_USER_ID = "gitUserId";
public static final String GIT_USER_ID_DESC = "Git user ID, e.g. openapitools.";

View File

@@ -408,8 +408,8 @@ public class InlineModelResolver {
private String uniqueName(String key) {
if (key == null) {
key = "NULL_UNIQUE_NAME";
LOGGER.warn("null key found. Default to NULL_UNIQUE_NAME");
key = "InlineObject";
LOGGER.warn("Found an inline schema without the `title` attribute. Default the model name to InlineObject instead. To have better control of the model naming, define the model separately so that it can be reused throughout the spec.");
}
int count = 0;
boolean done = false;

View File

@@ -232,16 +232,8 @@ public class ExampleGenerator {
Schema innerType = ((ArraySchema) property).getItems();
if (innerType != null) {
int arrayLength = null == ((ArraySchema) property).getMaxItems() ? 2 : ((ArraySchema) property).getMaxItems();
if (arrayLength == Integer.MAX_VALUE) {
// swagger-jersey2-jaxrs generated spec may contain maxItem = 2147483647
// semantically this means there is no upper limit
// treating this as if the property was not present at all
LOGGER.warn("The max items allowed in property {} of {} equals Integer.MAX_VALUE. Treating this as if no max items has been specified.", property, arrayLength);
arrayLength = 2;
} else if (arrayLength > 1024) {
LOGGER.warn("The max items allowed in property {} is too large ({} items), restricting it to 1024 items", property, arrayLength);
arrayLength = 1024;
}
// avoid memory issues by limiting to max. 5 items
arrayLength = Math.min(arrayLength, 5);
Object[] objectProperties = new Object[arrayLength];
Object objProperty = resolvePropertyToExample(propertyName, mediaType, innerType, processedModels);
for (int i = 0; i < arrayLength; i++) {

View File

@@ -39,7 +39,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
protected boolean optionalAssemblyInfoFlag = true;
protected boolean optionalProjectFileFlag = true;
protected boolean optionalEmitDefaultValue = false;
protected boolean optionalMethodArgumentFlag = true;
protected boolean useDateTimeOffsetFlag = false;
protected boolean useCollection = false;
@@ -197,10 +196,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
this.returnICollection = returnICollection;
}
public void setOptionalEmitDefaultValue(boolean optionalEmitDefaultValue) {
this.optionalEmitDefaultValue = optionalEmitDefaultValue;
}
public void setUseCollection(boolean useCollection) {
this.useCollection = useCollection;
if (useCollection) {
@@ -339,12 +334,6 @@ public abstract class AbstractCSharpCodegen extends DefaultCodegen implements Co
additionalProperties.put(CodegenConstants.RETURN_ICOLLECTION, returnICollection);
}
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES)) {
setOptionalEmitDefaultValue(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES));
} else {
additionalProperties.put(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES, optionalEmitDefaultValue);
}
if (additionalProperties.containsKey(CodegenConstants.NETCORE_PROJECT_FILE)) {
setNetCoreProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.NETCORE_PROJECT_FILE));
} else {

View File

@@ -20,10 +20,7 @@ package org.openapitools.codegen.languages;
import com.samskivert.mustache.Mustache;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.media.Schema;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.CodegenType;
import org.openapitools.codegen.SupportingFile;
import org.openapitools.codegen.*;
import org.openapitools.codegen.utils.URLPathUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,6 +45,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
public static final String PROJECT_SDK = "projectSdk";
public static final String SDK_WEB = "Microsoft.NET.Sdk.Web";
public static final String SDK_LIB = "Microsoft.NET.Sdk";
public static final String COMPATIBILITY_VERSION = "compatibilityVersion";
private String packageGuid = "{" + randomUUID().toString().toUpperCase(Locale.ROOT) + "}";
@@ -57,13 +55,13 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
private boolean useSwashbuckle = true;
protected int serverPort = 8080;
protected String serverHost = "0.0.0.0";
protected String aspnetCoreVersion= "2.1"; // default to 2.1
// TODO Make next two enums toensure fixed list.
private String classModifier = "";
private String operationModifier = "virtual";
private CliOption aspnetCoreVersion = new CliOption(ASPNET_CORE_VERSION, "ASP.NET Core version: 2.2 (default), 2.1, 2.0 (deprecated)");
private CliOption classModifier = new CliOption(CLASS_MODIFIER, "Class Modifier can be empty, abstract");
private CliOption operationModifier = new CliOption(OPERATION_MODIFIER, "Operation Modifier can be virtual, abstract or partial");
private boolean generateBody = true;
private String buildTarget = "program";
private CliOption buildTarget = new CliOption("buildTarget", "Target to build an application or library");
private String projectSdk = SDK_WEB;
private String compatibilityVersion = "Version_2_1";
public AspNetCoreServerCodegen() {
super();
@@ -132,9 +130,14 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
CodegenConstants.SOURCE_FOLDER_DESC,
sourceFolder);
addOption(ASPNET_CORE_VERSION,
"ASP.NET Core version: 2.1 (default), 2.0 (deprecated)",
aspnetCoreVersion);
addOption(COMPATIBILITY_VERSION, "ASP.Net Core CompatibilityVersion", compatibilityVersion);
aspnetCoreVersion.addEnum("2.0", "ASP.NET COre V2.0");
aspnetCoreVersion.addEnum("2.1", "ASP.NET COre V2.1");
aspnetCoreVersion.addEnum("2.2", "ASP.NET COre V2.2");
aspnetCoreVersion.setDefault("2.2");
aspnetCoreVersion.setOptValue(aspnetCoreVersion.getDefault());
addOption(aspnetCoreVersion.getOpt(), aspnetCoreVersion.getDescription(), aspnetCoreVersion.getOptValue());
// CLI Switches
addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
@@ -157,22 +160,28 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
"Uses the Swashbuckle.AspNetCore NuGet package for documentation.",
useSwashbuckle);
addOption(CLASS_MODIFIER,
"Class modifiers such as abstract or partial",
classModifier);
classModifier.addEnum("", "Keep class default with no modifier");
classModifier.addEnum("abstract", "Make class abstract");
classModifier.setDefault("");
classModifier.setOptValue(classModifier.getDefault());
addOption(classModifier.getOpt(), classModifier.getDescription(), classModifier.getOptValue());
addOption(OPERATION_MODIFIER,
"Operation modifiers such as virtual or abstract.",
operationModifier);
operationModifier.addEnum("virtual", "Keep method virtual ");
operationModifier.addEnum("abstract", "Make method abstract");
operationModifier.setDefault("virtual");
operationModifier.setOptValue(operationModifier.getDefault());
addOption(operationModifier.getOpt(), operationModifier.getDescription(), operationModifier.getOptValue());
buildTarget.addEnum("program", "Generate code for standalone server");
buildTarget.addEnum("library", "Generate code for a server abstract class lbrary");
buildTarget.setDefault("program");
buildTarget.setOptValue(buildTarget.getDefault());
addOption(buildTarget.getOpt(), buildTarget.getDescription(), buildTarget.getOptValue());
addSwitch(GENERATE_BODY,
"Generates method body.",
generateBody);
addOption(BUILD_TARGET,
"Target the build for a program or library.",
buildTarget);
}
@Override
@@ -214,53 +223,15 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
additionalProperties.put(USE_SWASHBUCKLE, useSwashbuckle);
}
// determine the ASP.NET core version setting
if (additionalProperties.containsKey(ASPNET_CORE_VERSION)) {
setAspnetCoreVersion((String) additionalProperties.get(ASPNET_CORE_VERSION));
}
// CHeck for the modifiers etc.
// The order of the checks is important.
isLibrary = setBuildTarget();
setClassModifier();
setOperationModifier();
// CHeck for class modifier if not present set the default value.
if (additionalProperties.containsKey(CLASS_MODIFIER)) {
classModifier = additionalProperties.get(CLASS_MODIFIER).toString();
} else {
additionalProperties.put(CLASS_MODIFIER, classModifier);
}
// TODO Validate modifier values
// If class modifierier is abstract then the methods need to be abstrat too.
if ("abstract".equals(classModifier)) {
operationModifier = classModifier;
additionalProperties.put(OPERATION_MODIFIER, operationModifier);
}
if (additionalProperties.containsKey(OPERATION_MODIFIER)) {
operationModifier = additionalProperties.get(OPERATION_MODIFIER).toString();
} else {
additionalProperties.put(OPERATION_MODIFIER, operationModifier);
}
// TODO Validate modifier values
// If operation modifier is abstract then dont generate any body
if ("abstract".equals(operationModifier)) {
generateBody = false;
additionalProperties.put(GENERATE_BODY, generateBody);
}
if (additionalProperties.containsKey(GENERATE_BODY)) {
generateBody = convertPropertyToBooleanAndWriteBack(GENERATE_BODY);
} else {
additionalProperties.put(GENERATE_BODY, generateBody);
}
// CHeck for class modifier if not present set the default value.
if (additionalProperties.containsKey(BUILD_TARGET)) {
buildTarget = additionalProperties.get(BUILD_TARGET).toString();
} else {
additionalProperties.put(BUILD_TARGET, buildTarget);
}
if ("library".equals(buildTarget)) {
isLibrary = true;
projectSdk = SDK_LIB;
}
additionalProperties.put(PROJECT_SDK, projectSdk);
additionalProperties.put("dockerTag", packageName.toLowerCase(Locale.ROOT));
@@ -270,17 +241,8 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
String packageFolder = sourceFolder + File.separator + packageName;
if ("2.0".equals(aspnetCoreVersion)) {
embeddedTemplateDir = templateDir = "aspnetcore/2.0";
supportingFiles.add(new SupportingFile("web.config", packageFolder, "web.config"));
LOGGER.info("ASP.NET core version: 2.0");
} else if ("2.1".equals(aspnetCoreVersion)) {
// default, do nothing
LOGGER.info("ASP.NET core version: 2.1");
} else {
throw new IllegalArgumentException("aspnetCoreVersion must be '2.1', '2.0' but found " + aspnetCoreVersion);
}
// determine the ASP.NET core version setting
setAspnetCoreVersion(packageFolder);
supportingFiles.add(new SupportingFile("build.sh.mustache", "", "build.sh"));
supportingFiles.add(new SupportingFile("build.bat.mustache", "", "build.bat"));
@@ -307,26 +269,6 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "openapi-original.mustache",
packageFolder + File.separator + "wwwroot", "openapi-original.json"));
}
supportingFiles.add(new SupportingFile("validateModel.mustache", packageFolder + File.separator + "Attributes", "ValidateModelStateAttribute.cs"));
supportingFiles.add(new SupportingFile("Project.csproj.mustache", packageFolder, packageName + ".csproj"));
if (!isLibrary) {
supportingFiles.add(new SupportingFile("Dockerfile.mustache", packageFolder, "Dockerfile"));
supportingFiles.add(new SupportingFile("appsettings.json", packageFolder, "appsettings.json"));
supportingFiles.add(new SupportingFile("Startup.mustache", packageFolder, "Startup.cs"));
supportingFiles.add(new SupportingFile("Program.mustache", packageFolder, "Program.cs"));
supportingFiles.add(new SupportingFile("Properties" + File.separator + "launchSettings.json",
packageFolder + File.separator + "Properties", "launchSettings.json"));
} else {
supportingFiles.add(new SupportingFile("Project.nuspec.mustache", packageFolder, packageName + ".nuspec"));
// wwwroot files.
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "README.md", packageFolder + File.separator + "wwwroot", "README.md"));
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "index.html", packageFolder + File.separator + "wwwroot", "index.html"));
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "web.config", packageFolder + File.separator + "wwwroot", "web.config"));
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "openapi-original.mustache",
packageFolder + File.separator + "wwwroot", "openapi-original.json"));
}
if (useSwashbuckle) {
@@ -341,10 +283,6 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
this.packageGuid = packageGuid;
}
public void setAspnetCoreVersion(String aspnetCoreVersion) {
this.aspnetCoreVersion= aspnetCoreVersion;
}
@Override
public String apiFileFolder() {
return outputFolder + File.separator + sourceFolder + File.separator + packageName + File.separator + "Controllers";
@@ -388,7 +326,7 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
public String toRegularExpression(String pattern) {
return escapeText(pattern);
}
@Override
public String getNullableType(Schema p, String type) {
boolean isNullableExpected = p.getNullable() == null || (p.getNullable() != null && p.getNullable());
@@ -401,4 +339,72 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
return null;
}
}
private void setCliOption(CliOption cliOption) throws IllegalArgumentException {
if (additionalProperties.containsKey(cliOption.getOpt())) {
cliOption.setOptValue(additionalProperties.get(cliOption.getOpt()).toString());
if (cliOption.getOptValue() == null) {
cliOption.setOptValue(cliOption.getDefault());
throw new IllegalArgumentException(cliOption.getOpt() + ": Invalid value '" + additionalProperties.get(cliOption.getOpt()).toString() + "'" +
". " + cliOption.getDescription());
}
} else {
additionalProperties.put(cliOption.getOpt(), cliOption.getOptValue());
}
}
private void setClassModifier() {
// CHeck for class modifier if not present set the default value.
setCliOption(classModifier);
// If class modifier is abstract then the methods need to be abstract too.
if ("abstract".equals(classModifier.getOptValue())) {
operationModifier.setOptValue(classModifier.getOptValue());
additionalProperties.put(OPERATION_MODIFIER, operationModifier.getOptValue());
LOGGER.warn("classModifier is " + classModifier.getOptValue() + " so forcing operatonModifier to " + operationModifier.getOptValue());
} else {
setCliOption(operationModifier);
}
}
private void setOperationModifier() {
setCliOption(operationModifier);
// If operation modifier is abstract then dont generate any body
if ("abstract".equals(operationModifier.getOptValue())) {
generateBody = false;
additionalProperties.put(GENERATE_BODY, generateBody);
LOGGER.warn("operationModifier is " + operationModifier.getOptValue() + " so forcing generateBody to " + generateBody);
} else if (additionalProperties.containsKey(GENERATE_BODY)) {
generateBody = convertPropertyToBooleanAndWriteBack(GENERATE_BODY);
} else {
additionalProperties.put(GENERATE_BODY, generateBody);
}
}
private boolean setBuildTarget() {
boolean isLibrary = false;
setCliOption(buildTarget);
if ("library".equals(buildTarget.getOptValue())) {
isLibrary = true;
projectSdk = SDK_LIB;
additionalProperties.put(CLASS_MODIFIER, "abstract");
}
return isLibrary;
}
private void setAspnetCoreVersion(String packageFolder) {
setCliOption(aspnetCoreVersion);
if ("2.0".equals(aspnetCoreVersion.getOptValue())) {
embeddedTemplateDir = templateDir = "aspnetcore/2.0";
supportingFiles.add(new SupportingFile("web.config", packageFolder, "web.config"));
LOGGER.info("ASP.NET core version: 2.0");
compatibilityVersion = null;
} else {
// default, do nothing
LOGGER.info("ASP.NET core version: " + aspnetCoreVersion.getOptValue());
compatibilityVersion = "Version_" + aspnetCoreVersion.getOptValue().replace(".", "_");
}
additionalProperties.put(COMPATIBILITY_VERSION, compatibilityVersion);
}
}

View File

@@ -170,10 +170,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
CodegenConstants.OPTIONAL_PROJECT_FILE_DESC,
this.optionalProjectFileFlag);
addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES,
CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC,
this.optionalEmitDefaultValue);
addSwitch(CodegenConstants.GENERATE_PROPERTY_CHANGED,
CodegenConstants.PACKAGE_DESCRIPTION_DESC,
this.generatePropertyChanged);
@@ -330,9 +326,6 @@ public class CSharpClientCodegen extends AbstractCSharpCodegen {
additionalProperties.put("netStandard", this.netStandard);
additionalProperties.put("targetFrameworkNuget", this.targetFrameworkNuget);
// TODO: either remove this and update templates to match the "optionalEmitDefaultValues" property, or rename that property.
additionalProperties.put("emitDefaultValue", optionalEmitDefaultValue);
if (additionalProperties.containsKey(CodegenConstants.OPTIONAL_PROJECT_FILE)) {
setOptionalProjectFileFlag(convertPropertyToBooleanAndWriteBack(CodegenConstants.OPTIONAL_PROJECT_FILE));
} else {

View File

@@ -184,10 +184,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
CodegenConstants.OPTIONAL_PROJECT_FILE_DESC,
this.optionalProjectFileFlag);
addSwitch(CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES,
CodegenConstants.OPTIONAL_EMIT_DEFAULT_VALUES_DESC,
this.optionalEmitDefaultValue);
// NOTE: This will reduce visibility of all public members in templates. Users can use InternalsVisibleTo
// https://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute(v=vs.110).aspx
// to expose to shared code if the generated code is not embedded into another project. Otherwise, users of codegen
@@ -510,8 +506,6 @@ public class CSharpNetCoreClientCodegen extends AbstractCSharpCodegen {
syncBooleanProperty(additionalProperties, "netStandard", this::setNetStandard, this.netStandard);
// TODO: either remove this and update templates to match the "optionalEmitDefaultValues" property, or rename that property.
syncBooleanProperty(additionalProperties, "emitDefaultValue", this::setOptionalEmitDefaultValue, optionalEmitDefaultValue);
syncBooleanProperty(additionalProperties, CodegenConstants.VALIDATABLE, this::setValidatable, this.validatable);
syncBooleanProperty(additionalProperties, CodegenConstants.SUPPORTS_ASYNC, this::setSupportsAsync, this.supportsAsync);
syncBooleanProperty(additionalProperties, CodegenConstants.OPTIONAL_PROJECT_FILE, this::setOptionalProjectFileFlag, optionalProjectFileFlag);

View File

@@ -120,7 +120,7 @@ public class OAuth implements RequestInterceptor {
public synchronized void setAccessToken(String accessToken, Long expiresIn) {
this.accessToken = accessToken;
this.expirationTimeMillis = System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
this.expirationTimeMillis = expiresIn == null ? null : System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
}
public TokenRequestBuilder getTokenRequestBuilder() {

View File

@@ -1,4 +1,4 @@
FROM microsoft/dotnet:2.1-sdk AS build-env
FROM microsoft/dotnet:{{aspnetCoreVersion}}-sdk AS build-env
WORKDIR /app
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
@@ -12,7 +12,7 @@ COPY . ./
RUN dotnet publish -c Release -o out
# build runtime image
FROM microsoft/dotnet:2.1-aspnetcore-runtime
FROM microsoft/dotnet:{{aspnetCoreVersion}}-aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "{{packageName}}.dll"]

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<Description>{{packageName}}</Description>
<Copyright>{{packageName}}</Copyright>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp{{aspnetCoreVersion}}</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>{{packageName}}</AssemblyName>

View File

@@ -43,7 +43,9 @@ namespace {{packageName}}
// Add framework services.
services
.AddMvc()
.SetCompatibilityVersion (CompatibilityVersion.Version_2_1)
{{#compatibilityVersion}}
.SetCompatibilityVersion(CompatibilityVersion.{{compatibilityVersion}})
{{/compatibilityVersion}}
.AddJsonOptions(opts =>
{
opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
@@ -107,7 +109,7 @@ namespace {{packageName}}
// c.SwaggerEndpoint("/openapi-original.json", "{{#appName}}{{{appName}}}{{/appName}}{{^appName}}{{packageName}}{{/appName}} Original");
}){{/useSwashbuckle}};
if (env.IsDevelopment())
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

View File

@@ -28,7 +28,7 @@ namespace {{packageName}}.Controllers
[ValidateModelState]{{#useSwashbuckle}}
[SwaggerOperation("{{operationId}}")]{{#responses}}{{#dataType}}
[SwaggerResponse(statusCode: {{code}}, type: typeof({{&dataType}}), description: "{{message}}")]{{/dataType}}{{^dataType}}{{/dataType}}{{/responses}}{{/useSwashbuckle}}
public {{operationModifier}} IActionResult {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
public {{operationModifier}} IActionResult {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}}){{^generateBody}};{{/generateBody}}
{{#generateBody}}
{ {{#responses}}
{{#dataType}}
@@ -51,9 +51,6 @@ namespace {{packageName}}.Controllers
throw new NotImplementedException();{{/returnType}}
}
{{/generateBody}}
{{^generateBody}}
;
{{/generateBody}}
{{/operation}}
}
{{/operations}}

View File

@@ -33,7 +33,7 @@
{{#description}}
/// <value>{{description}}</value>
{{/description}}
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/isNullable}})]
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})]
public {{#complexType}}{{{complexType}}}{{/complexType}}{{^complexType}}{{{datatypeWithEnum}}}{{/complexType}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}} {{name}} { get; set; }
{{/isEnum}}
{{/vars}}
@@ -116,7 +116,7 @@
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
/// </summary>{{#description}}
/// <value>{{description}}</value>{{/description}}
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/isNullable}})]{{#isDate}}
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})]{{#isDate}}
[JsonConverter(typeof(OpenAPIDateConverter))]{{/isDate}}
public {{{dataType}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; }

View File

@@ -31,7 +31,7 @@
{{#description}}
/// <value>{{description}}</value>
{{/description}}
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/isNullable}})]
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})]
public {{#complexType}}{{{complexType}}}{{/complexType}}{{^complexType}}{{{datatypeWithEnum}}}{{/complexType}}{{^isContainer}}{{^required}}?{{/required}}{{/isContainer}} {{name}} { get; set; }
{{/isEnum}}
{{/vars}}
@@ -108,7 +108,7 @@ this.{{name}} = {{#lambda.camelcase_param}}{{name}}{{/lambda.camelcase_param}};
/// {{^description}}Gets or Sets {{{name}}}{{/description}}{{#description}}{{description}}{{/description}}
/// </summary>{{#description}}
/// <value>{{description}}</value>{{/description}}
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/isNullable}})]{{#isDate}}
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})]{{#isDate}}
[JsonConverter(typeof(OpenAPIDateConverter))]{{/isDate}}
public {{{dataType}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; }
{{/isEnum}}

View File

@@ -21,8 +21,8 @@ import io.swagger.v3.oas.models.Components;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.headers.Header;
import io.swagger.v3.oas.models.media.*;
import io.swagger.v3.oas.models.parameters.QueryParameter;
import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.responses.ApiResponse;

View File

@@ -9,15 +9,13 @@ import io.swagger.v3.oas.models.media.StringSchema;
import io.swagger.v3.oas.models.parameters.QueryParameter;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.responses.ApiResponses;
import java.io.File;
import java.io.IOException;
import org.testng.Assert;
import org.testng.annotations.Test;
import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
public class DefaultGeneratorTest {

View File

@@ -378,7 +378,7 @@ public class InlineModelResolverTest {
ArraySchema requestBody = (ArraySchema) mediaType.getSchema();
assertNotNull(requestBody.getItems().get$ref());
assertEquals("#/components/schemas/NULL_UNIQUE_NAME", requestBody.getItems().get$ref());
assertEquals("#/components/schemas/InlineObject", requestBody.getItems().get$ref());
Schema items = ModelUtils.getReferencedSchema(openAPI, ((ArraySchema) mediaType.getSchema()).getItems());
assertTrue(items.getProperties().get("street") instanceof StringSchema);

View File

@@ -264,7 +264,10 @@ public class AbstractJavaCodegenTest {
/**
* Gets artifact version.
* Only for testing purposes.
* @return version
*/
public String getArtifactVersion () { return this.artifactVersion; }
public String getArtifactVersion() {
return this.artifactVersion;
}
}
}

View File

@@ -28,7 +28,6 @@ import io.swagger.v3.oas.models.parameters.RequestBody;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.responses.ApiResponses;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.junit.rules.TemporaryFolder;
import org.openapitools.codegen.*;
import org.openapitools.codegen.config.CodegenConfigurator;
import org.openapitools.codegen.languages.JavaClientCodegen;
@@ -37,10 +36,10 @@ import org.testng.annotations.DataProvider;
import org.testng.annotations.Test;
import java.io.File;
import java.nio.file.Files;
import java.util.List;
public class JavaModelTest {
private TemporaryFolder folder = new TemporaryFolder();
@Test(description = "convert a simple java model")
public void simpleModelTest() {
@@ -1215,8 +1214,9 @@ public class JavaModelTest {
public void generateModel() throws Exception {
String inputSpec = "src/test/resources/3_0/petstore.json";
folder.create();
final File output = folder.getRoot();
final File output = Files.createTempDirectory("test").toFile();
output.deleteOnExit();
Assert.assertTrue(new File(inputSpec).exists());
final CodegenConfigurator configurator = new CodegenConfigurator()
@@ -1232,15 +1232,14 @@ public class JavaModelTest {
File orderFile = new File(output, "src/main/java/org/openapitools/client/model/Order.java");
Assert.assertTrue(orderFile.exists());
folder.delete();
}
@Test
public void generateEmpty() throws Exception {
String inputSpec = "src/test/resources/3_0/ping.yaml";
folder.create();
final File output = folder.getRoot();
final File output = Files.createTempDirectory("test").toFile();
output.deleteOnExit();
Assert.assertTrue(new File(inputSpec).exists());
JavaClientCodegen config = new org.openapitools.codegen.languages.JavaClientCodegen();
@@ -1258,6 +1257,5 @@ public class JavaModelTest {
File orderFile = new File(output, "src/main/java/org/openapitools/client/api/DefaultApi.java");
Assert.assertTrue(orderFile.exists());
folder.delete();
}
}

View File

@@ -1,9 +1,17 @@
package org.openapitools.codegen.java.jaxrs;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
import static org.testng.Assert.assertTrue;
import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.parser.core.models.ParseOptions;
import org.openapitools.codegen.*;
import org.openapitools.codegen.MockDefaultGenerator.WrittenTemplateBasedFile;
import org.openapitools.codegen.languages.AbstractJavaCodegen;
import org.openapitools.codegen.languages.AbstractJavaJAXRSServerCodegen;
import org.openapitools.codegen.languages.JavaCXFExtServerCodegen;
import org.openapitools.codegen.languages.features.*;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.File;
import java.nio.file.Files;
@@ -11,36 +19,7 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Pattern;
import org.openapitools.codegen.ClientOptInput;
import org.openapitools.codegen.ClientOpts;
import org.openapitools.codegen.CodegenConstants;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.MockDefaultGenerator;
import org.openapitools.codegen.MockDefaultGenerator.WrittenTemplateBasedFile;
import org.openapitools.codegen.TestUtils;
import org.openapitools.codegen.languages.AbstractJavaCodegen;
import org.openapitools.codegen.languages.AbstractJavaJAXRSServerCodegen;
import org.openapitools.codegen.languages.JavaCXFExtServerCodegen;
import org.openapitools.codegen.languages.features.BeanValidationExtendedFeatures;
import org.openapitools.codegen.languages.features.BeanValidationFeatures;
import org.openapitools.codegen.languages.features.CXFExtServerFeatures;
import org.openapitools.codegen.languages.features.CXFServerFeatures;
import org.openapitools.codegen.languages.features.GzipFeatures;
import org.openapitools.codegen.languages.features.GzipTestFeatures;
import org.openapitools.codegen.languages.features.JbossFeature;
import org.openapitools.codegen.languages.features.LoggingFeatures;
import org.openapitools.codegen.languages.features.LoggingTestFeatures;
import org.openapitools.codegen.languages.features.SpringFeatures;
import org.openapitools.codegen.languages.features.SwaggerFeatures;
import org.openapitools.codegen.languages.features.SwaggerUIFeatures;
import org.openapitools.codegen.languages.features.UseGenericResponseFeatures;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import io.swagger.parser.OpenAPIParser;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.servers.Server;
import io.swagger.v3.parser.core.models.ParseOptions;
import static org.testng.Assert.*;
public class JavaJAXRSCXFExtServerCodegenTest {
@SuppressWarnings("unused")

View File

@@ -1,18 +1,16 @@
package org.openapitools.codegen.java.jaxrs;
import io.swagger.v3.oas.models.Operation;
import org.junit.Before;
import org.junit.Test;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen;
import org.testng.Assert;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
/**
* Unit-Test for {@link org.openapitools.codegen.languages.JavaJAXRSSpecServerCodegen}.
*
@@ -22,7 +20,7 @@ public class JavaJAXRSSpecServerCodegenTest {
private JavaJAXRSSpecServerCodegen instance;
@Before
@BeforeMethod
public void before() {
instance = new JavaJAXRSSpecServerCodegen();
}
@@ -40,9 +38,9 @@ public class JavaJAXRSSpecServerCodegenTest {
instance.addOperationToGroup("Primaryresource", "/", operation, codegenOperation, operationList);
assertThat(operationList.size(), is(1));
assertThat(operationList.containsKey(""), is(true));
assertThat(codegenOperation.baseName, is("Primaryresource"));
Assert.assertEquals(operationList.size(), 1);
Assert.assertTrue(operationList.containsKey(""));
Assert.assertEquals(codegenOperation.baseName, "Primaryresource");
}
/**
@@ -58,9 +56,9 @@ public class JavaJAXRSSpecServerCodegenTest {
instance.addOperationToGroup("Primaryresource", "/{uuid}", operation, codegenOperation, operationList);
assertThat(operationList.size(), is(1));
assertThat(operationList.containsKey(""), is(true));
assertThat(codegenOperation.baseName, is("Primaryresource"));
Assert.assertEquals(operationList.size(), 1);
Assert.assertTrue(operationList.containsKey(""));
Assert.assertEquals(codegenOperation.baseName, "Primaryresource");
}
/**
@@ -77,9 +75,9 @@ public class JavaJAXRSSpecServerCodegenTest {
instance.addOperationToGroup("Default", "/subresource", operation, codegenOperation, operationList);
assertThat(codegenOperation.baseName, is("subresource"));
assertThat(operationList.size(), is(1));
assertThat(operationList.containsKey("subresource"), is(true));
Assert.assertEquals(codegenOperation.baseName, "subresource");
Assert.assertEquals(operationList.size(), 1);
Assert.assertTrue(operationList.containsKey("subresource"));
}
/**
@@ -88,7 +86,7 @@ public class JavaJAXRSSpecServerCodegenTest {
@Test
public void testToApiNameForSubresource() {
final String subresource = instance.toApiName("subresource");
assertThat(subresource, is("SubresourceApi"));
Assert.assertEquals(subresource, "SubresourceApi");
}
/**
@@ -103,6 +101,6 @@ public class JavaJAXRSSpecServerCodegenTest {
instance.addOperationToGroup("Primaryresource", "/", operation, codegenOperation, operationList);
final String subresource = instance.toApiName("");
assertThat(subresource, is("PrimaryresourceApi"));
Assert.assertEquals(subresource, "PrimaryresourceApi");
}
}

View File

@@ -21,16 +21,14 @@ import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import io.swagger.v3.oas.models.media.Schema;
import org.apache.commons.io.FileUtils;
import org.junit.rules.TemporaryFolder;
import org.openapitools.codegen.*;
import org.openapitools.codegen.languages.RubyClientCodegen;
import org.testng.Assert;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import java.io.File;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Set;
@@ -44,21 +42,12 @@ import static org.testng.Assert.fail;
*/
public class RubyClientCodegenTest {
public TemporaryFolder folder = new TemporaryFolder();
@BeforeMethod
public void setUp() throws Exception {
folder.create();
}
@AfterMethod
public void tearDown() throws Exception {
folder.delete();
}
@Test
public void testGenerateRubyClientWithHtmlEntity() throws Exception {
final File output = folder.getRoot();
final File output = Files.createTempDirectory("test").toFile();
output.mkdirs();
output.deleteOnExit();
final OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/2_0/pathWithHtmlEntity.yaml");
CodegenConfig codegenConfig = new RubyClientCodegen();
@@ -120,7 +109,9 @@ public class RubyClientCodegenTest {
@Test
public void testBooleanDefaultValue() throws Exception {
final File output = folder.getRoot();
final File output = Files.createTempDirectory("test").toFile();
output.mkdirs();
output.deleteOnExit();
final OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/2_0/npe1.yaml");
CodegenConfig codegenConfig = new RubyClientCodegen();

View File

@@ -1,8 +1,8 @@
package org.openapitools.codegen.typescript.fetch;
import org.junit.Assert;
import org.junit.Test;
import org.openapitools.codegen.languages.TypeScriptFetchClientCodegen;
import org.testng.Assert;
import org.testng.annotations.Test;
public class TypeScriptFetchClientCodegenTest {

View File

@@ -1,15 +1,15 @@
package org.openapitools.codegen.typescript.typescriptangular;
import org.junit.Assert;
import org.junit.Test;
import org.openapitools.codegen.languages.TypeScriptAngularClientCodegen;
import org.openapitools.codegen.TestUtils;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.Operation;
import org.openapitools.codegen.CodegenOperation;
import io.swagger.v3.oas.models.PathItem;
import io.swagger.v3.oas.models.responses.ApiResponse;
import io.swagger.v3.oas.models.responses.ApiResponses;
import org.openapitools.codegen.CodegenOperation;
import org.openapitools.codegen.TestUtils;
import org.openapitools.codegen.languages.TypeScriptAngularClientCodegen;
import org.testng.Assert;
import org.testng.annotations.Test;
public class TypeScriptAngularClientCodegenTest {

View File

@@ -1,10 +1,10 @@
package org.openapitools.codegen.typescript.typescriptangular;
import io.swagger.v3.oas.models.OpenAPI;
import org.junit.Assert;
import org.junit.Test;
import org.openapitools.codegen.TestUtils;
import org.openapitools.codegen.languages.TypeScriptAngularClientCodegen;
import org.testng.Assert;
import org.testng.annotations.Test;
public class TypescriptAngularApiVersionTest {

View File

@@ -26,7 +26,7 @@ public class TypeScriptNodeClientCodegenTest {
codegen.additionalProperties().put("npmVersion", "1.0.0-SNAPSHOT");
codegen.processOpts();
org.junit.Assert.assertTrue(codegen.getNpmVersion().matches("^1.0.0-SNAPSHOT.[0-9]{12}$"));
Assert.assertTrue(codegen.getNpmVersion().matches("^1.0.0-SNAPSHOT.[0-9]{12}$"));
codegen = new TypeScriptNodeClientCodegen();
codegen.additionalProperties().put("npmName", "@openapi/typescript-angular-petstore");
@@ -34,7 +34,7 @@ public class TypeScriptNodeClientCodegenTest {
codegen.additionalProperties().put("npmVersion", "3.0.0-M1");
codegen.processOpts();
org.junit.Assert.assertTrue(codegen.getNpmVersion().matches("^3.0.0-M1-SNAPSHOT.[0-9]{12}$"));
Assert.assertTrue(codegen.getNpmVersion().matches("^3.0.0-M1-SNAPSHOT.[0-9]{12}$"));
}
@@ -46,7 +46,7 @@ public class TypeScriptNodeClientCodegenTest {
codegen.additionalProperties().put("npmVersion", "1.0.0-SNAPSHOT");
codegen.processOpts();
org.junit.Assert.assertTrue(codegen.getNpmVersion().matches("^1.0.0-SNAPSHOT$"));
Assert.assertTrue(codegen.getNpmVersion().matches("^1.0.0-SNAPSHOT$"));
codegen = new TypeScriptNodeClientCodegen();
codegen.additionalProperties().put("npmName", "@openapi/typescript-angular-petstore");
@@ -54,7 +54,7 @@ public class TypeScriptNodeClientCodegenTest {
codegen.additionalProperties().put("npmVersion", "3.0.0-M1");
codegen.processOpts();
org.junit.Assert.assertTrue(codegen.getNpmVersion().matches("^3.0.0-M1$"));
Assert.assertTrue(codegen.getNpmVersion().matches("^3.0.0-M1$"));
}

View File

@@ -3,9 +3,7 @@ package org.openapitools.codegen.utils;
import org.testng.Assert;
import org.testng.annotations.Test;
import static org.openapitools.codegen.utils.StringUtils.camelize;
import static org.openapitools.codegen.utils.StringUtils.dashize;
import static org.openapitools.codegen.utils.StringUtils.underscore;
import static org.openapitools.codegen.utils.StringUtils.*;
public class StringUtilsTest {
// we'll assume that <i>underscore</i> (Twitter elephant bird) works fine

22
pom.xml
View File

@@ -9,7 +9,7 @@
<artifactId>openapi-generator-project</artifactId>
<packaging>pom</packaging>
<name>openapi-generator-project</name>
<version>4.0.0-SNAPSHOT</version>
<version>4.0.0-beta3</version>
<url>https://github.com/openapitools/openapi-generator</url>
<scm>
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
@@ -157,23 +157,11 @@
<version>${surefire-version}</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<testNGArtifactName>none:none</testNGArtifactName>
<junitArtifactName>none:none</junitArtifactName>
<testNGArtifactName>org.testng:testng</testNGArtifactName>
<argLine>-XX:+StartAttachListener</argLine>
<argLine>-javaagent:"${settings.localRepository}/org/jmockit/jmockit/${jmockit-version}/jmockit-${jmockit-version}.jar"</argLine>
</configuration>
<executions>
<execution>
<id>test-testng</id>
<phase>test</phase>
<goals>
<goal>test</goal>
</goals>
<configuration>
<junitArtifactName>none:none</junitArtifactName>
<testNGArtifactName>org.testng:testng</testNGArtifactName>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<artifactId>maven-dependency-plugin</artifactId>
@@ -1383,8 +1371,8 @@
<slf4j-version>1.7.12</slf4j-version>
<scala-maven-plugin-version>3.2.1</scala-maven-plugin-version>
<jmustache-version>1.14</jmustache-version>
<testng-version>6.9.6</testng-version>
<surefire-version>2.22.0</surefire-version>
<testng-version>6.14.3</testng-version>
<surefire-version>2.22.1</surefire-version>
<jmockit-version>1.43</jmockit-version>
<reflections-version>0.9.10</reflections-version>
</properties>

View File

@@ -120,7 +120,8 @@ paths:
/pet/findByTags:
get:
deprecated: true
description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
description: Multiple tags can be provided with comma separated strings. Use
tag1, tag2, tag3 for testing.
operationId: findPetsByTags
parameters:
- description: Tags to filter by
@@ -332,7 +333,8 @@ paths:
x-codegen-request-body-name: body
/store/order/{order_id}:
delete:
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
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
@@ -352,7 +354,8 @@ paths:
tags:
- store
get:
description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
description: For valid response try integer IDs with value <= 5 or > 10. Other
values will generated exceptions
operationId: getOrderById
parameters:
- description: ID of pet that needs to be fetched
@@ -1072,7 +1075,8 @@ paths:
x-codegen-request-body-name: body
/fake/body-with-file-schema:
put:
description: For this test, the body for this request much reference a schema named `File`.
description: For this test, the body for this request much reference a schema
named `File`.
operationId: testBodyWithFileSchema
requestBody:
content:

View File

@@ -120,7 +120,8 @@ paths:
/pet/findByTags:
get:
deprecated: true
description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
description: Multiple tags can be provided with comma separated strings. Use
tag1, tag2, tag3 for testing.
operationId: findPetsByTags
parameters:
- description: Tags to filter by
@@ -332,7 +333,8 @@ paths:
x-codegen-request-body-name: body
/store/order/{order_id}:
delete:
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
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
@@ -352,7 +354,8 @@ paths:
tags:
- store
get:
description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
description: For valid response try integer IDs with value <= 5 or > 10. Other
values will generated exceptions
operationId: getOrderById
parameters:
- description: ID of pet that needs to be fetched
@@ -1072,7 +1075,8 @@ paths:
x-codegen-request-body-name: body
/fake/body-with-file-schema:
put:
description: For this test, the body for this request much reference a schema named `File`.
description: For this test, the body for this request much reference a schema
named `File`.
operationId: testBodyWithFileSchema
requestBody:
content:

View File

@@ -112,7 +112,7 @@ public class OAuth implements RequestInterceptor {
public synchronized void setAccessToken(String accessToken, Long expiresIn) {
this.accessToken = accessToken;
this.expirationTimeMillis = System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
this.expirationTimeMillis = expiresIn == null ? null : System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
}
public TokenRequestBuilder getTokenRequestBuilder() {

View File

@@ -113,7 +113,7 @@ public class OAuth implements RequestInterceptor {
public synchronized void setAccessToken(String accessToken, Long expiresIn) {
this.accessToken = accessToken;
this.expirationTimeMillis = System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
this.expirationTimeMillis = expiresIn == null ? null : System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
}
public TokenRequestBuilder getTokenRequestBuilder() {

View File

@@ -126,7 +126,7 @@
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<openapi-generator-version>4.0.0-SNAPSHOT</openapi-generator-version>
<openapi-generator-version>4.0.0-beta3</openapi-generator-version>
<maven-plugin-version>1.0.0</maven-plugin-version>
<junit-version>4.8.1</junit-version>
</properties>

View File

@@ -1,4 +1,4 @@
FROM microsoft/dotnet:2.1-sdk AS build-env
FROM microsoft/dotnet:2.2-sdk AS build-env
WORKDIR /app
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
@@ -12,7 +12,7 @@ COPY . ./
RUN dotnet publish -c Release -o out
# build runtime image
FROM microsoft/dotnet:2.1-aspnetcore-runtime
FROM microsoft/dotnet:2.2-aspnetcore-runtime
WORKDIR /app
COPY --from=build-env /app/out .
ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"]

View File

@@ -2,7 +2,7 @@
<PropertyGroup>
<Description>Org.OpenAPITools</Description>
<Copyright>Org.OpenAPITools</Copyright>
<TargetFramework>netcoreapp2.1</TargetFramework>
<TargetFramework>netcoreapp2.2</TargetFramework>
<GenerateDocumentationFile>true</GenerateDocumentationFile>
<PreserveCompilationContext>true</PreserveCompilationContext>
<AssemblyName>Org.OpenAPITools</AssemblyName>

View File

@@ -52,7 +52,7 @@ namespace Org.OpenAPITools
// Add framework services.
services
.AddMvc()
.SetCompatibilityVersion (CompatibilityVersion.Version_2_1)
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
.AddJsonOptions(opts =>
{
opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
@@ -114,7 +114,7 @@ namespace Org.OpenAPITools
// c.SwaggerEndpoint("/openapi-original.json", "OpenAPI Petstore Original");
});
if (env.IsDevelopment())
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}

View File

@@ -1,6 +1,7 @@
openapi: 3.0.1
info:
description: This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
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
@@ -118,7 +119,8 @@ paths:
/pet/findByTags:
get:
deprecated: true
description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
description: Multiple tags can be provided with comma separated strings. Use
tag1, tag2, tag3 for testing.
operationId: findPetsByTags
parameters:
- description: Tags to filter by
@@ -330,7 +332,8 @@ paths:
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
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
@@ -350,7 +353,8 @@ paths:
tags:
- store
get:
description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
description: For valid response try integer IDs with value <= 5 or > 10. Other
values will generated exceptions
operationId: getOrderById
parameters:
- description: ID of pet that needs to be fetched

View File

@@ -126,7 +126,8 @@ paths:
/pet/findByTags:
get:
deprecated: true
description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
description: Multiple tags can be provided with comma separated strings. Use
tag1, tag2, tag3 for testing.
operationId: findPetsByTags
parameters:
- description: Tags to filter by
@@ -352,7 +353,8 @@ paths:
- tag: store
/store/order/{order_id}:
delete:
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
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
@@ -374,7 +376,8 @@ paths:
x-tags:
- tag: store
get:
description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
description: For valid response try integer IDs with value <= 5 or > 10. Other
values will generated exceptions
operationId: getOrderById
parameters:
- description: ID of pet that needs to be fetched
@@ -1140,7 +1143,8 @@ paths:
- tag: $another-fake?
/fake/body-with-file-schema:
put:
description: For this test, the body for this request much reference a schema named `File`.
description: For this test, the body for this request much reference a schema
named `File`.
operationId: testBodyWithFileSchema
requestBody:
content:

View File

@@ -126,7 +126,8 @@ paths:
/pet/findByTags:
get:
deprecated: true
description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
description: Multiple tags can be provided with comma separated strings. Use
tag1, tag2, tag3 for testing.
operationId: findPetsByTags
parameters:
- description: Tags to filter by
@@ -352,7 +353,8 @@ paths:
- tag: store
/store/order/{order_id}:
delete:
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
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
@@ -374,7 +376,8 @@ paths:
x-tags:
- tag: store
get:
description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
description: For valid response try integer IDs with value <= 5 or > 10. Other
values will generated exceptions
operationId: getOrderById
parameters:
- description: ID of pet that needs to be fetched
@@ -1140,7 +1143,8 @@ paths:
- tag: $another-fake?
/fake/body-with-file-schema:
put:
description: For this test, the body for this request much reference a schema named `File`.
description: For this test, the body for this request much reference a schema
named `File`.
operationId: testBodyWithFileSchema
requestBody:
content:

View File

@@ -120,7 +120,8 @@ paths:
/pet/findByTags:
get:
deprecated: true
description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
description: Multiple tags can be provided with comma separated strings. Use
tag1, tag2, tag3 for testing.
operationId: findPetsByTags
parameters:
- description: Tags to filter by
@@ -332,7 +333,8 @@ paths:
x-codegen-request-body-name: body
/store/order/{order_id}:
delete:
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
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
@@ -352,7 +354,8 @@ paths:
tags:
- store
get:
description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
description: For valid response try integer IDs with value <= 5 or > 10. Other
values will generated exceptions
operationId: getOrderById
parameters:
- description: ID of pet that needs to be fetched

View File

@@ -131,7 +131,8 @@ paths:
/pet/findByTags:
get:
deprecated: true
description: Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
description: Multiple tags can be provided with comma separated strings. Use
tag1, tag2, tag3 for testing.
operationId: findPetsByTags
parameters:
- description: Tags to filter by
@@ -367,7 +368,8 @@ paths:
- tag: store
/store/order/{order_id}:
delete:
description: For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
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
@@ -390,7 +392,8 @@ paths:
x-tags:
- tag: store
get:
description: For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
description: For valid response try integer IDs with value <= 5 or > 10. Other
values will generated exceptions
operationId: getOrderById
parameters:
- description: ID of pet that needs to be fetched
@@ -1196,7 +1199,8 @@ paths:
- tag: $another-fake?
/fake/body-with-file-schema:
put:
description: For this test, the body for this request much reference a schema named `File`.
description: For this test, the body for this request much reference a schema
named `File`.
operationId: testBodyWithFileSchema
requestBody:
content:

View File

@@ -93,3 +93,8 @@
image: "img/companies/zalando.jpg"
infoLink: "https://www.zalando.com/"
pinned: true
-
caption: ZOZO Technologies
image: "img/companies/zozo-technologies.png"
infoLink: "https://tech.zozo.com/en/"
pinned: false

Binary file not shown.

After

Width:  |  Height:  |  Size: 29 KiB