mirror of
https://github.com/OpenAPITools/openapi-generator.git
synced 2025-12-03 17:00:43 +00:00
Compare commits
3 Commits
v4.0.0-bet
...
nodejs-fas
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
605030dfeb | ||
|
|
ecb11fbe7f | ||
|
|
5cd3a16e56 |
@@ -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)
|
||||
|
||||
|
||||
32
bin/nodejs-fastify-petstore-server.sh
Executable file
32
bin/nodejs-fastify-petstore-server.sh
Executable file
@@ -0,0 +1,32 @@
|
||||
#!/bin/sh
|
||||
|
||||
SCRIPT="$0"
|
||||
echo "# START SCRIPT: $SCRIPT"
|
||||
|
||||
while [ -h "$SCRIPT" ] ; do
|
||||
ls=`ls -ld "$SCRIPT"`
|
||||
link=`expr "$ls" : '.*-> \(.*\)$'`
|
||||
if expr "$link" : '/.*' > /dev/null; then
|
||||
SCRIPT="$link"
|
||||
else
|
||||
SCRIPT=`dirname "$SCRIPT"`/"$link"
|
||||
fi
|
||||
done
|
||||
|
||||
if [ ! -d "${APP_DIR}" ]; then
|
||||
APP_DIR=`dirname "$SCRIPT"`/..
|
||||
APP_DIR=`cd "${APP_DIR}"; pwd`
|
||||
fi
|
||||
|
||||
executable="./modules/openapi-generator-cli/target/openapi-generator-cli.jar"
|
||||
|
||||
if [ ! -f "$executable" ]
|
||||
then
|
||||
mvn -B clean package
|
||||
fi
|
||||
|
||||
# if you've executed sbt assembly previously it will use that instead.
|
||||
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
|
||||
ags="generate -t modules/openapi-generator/src/main/resources/nodejs-fastify-server -i modules/openapi-generator/src/test/resources/2_0/petstore.yaml -g nodejs-fastify-server -o samples/server/petstore/nodejs-fastify-server $@"
|
||||
|
||||
java $JAVA_OPTS -jar $executable $ags
|
||||
10
bin/windows/nodejs-fastify-petstore-server.bat
Executable file
10
bin/windows/nodejs-fastify-petstore-server.bat
Executable file
@@ -0,0 +1,10 @@
|
||||
set executable=.\modules\openapi-generator-cli\target\openapi-generator-cli.jar
|
||||
|
||||
If Not Exist %executable% (
|
||||
mvn clean package
|
||||
)
|
||||
|
||||
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M
|
||||
set ags=generate -t modules\openapi-generator\src\main\resources\nodejs-fastify-server -i modules\openapi-generator\src\test\resources\2_0\petstore.yaml -g nodejs-fastify-server -o samples\server\petstore\nodejs-fastify-server
|
||||
|
||||
java %JAVA_OPTS% -jar %executable% %ags%
|
||||
@@ -16,14 +16,13 @@ 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|
|
||||
|compatibilityVersion|ASP.Net Core CompatibilityVersion| |Version_2_1|
|
||||
|aspnetCoreVersion|ASP.NET Core version: 2.2 (default), 2.1, 2.0 (deprecated)| |2.2|
|
||||
|aspnetCoreVersion|ASP.NET Core version: 2.1 (default), 2.0 (deprecated)| |2.1|
|
||||
|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 Modifier can be empty, abstract| ||
|
||||
|operationModifier|Operation Modifier can be virtual, abstract or partial| |virtual|
|
||||
|buildTarget|Target to build an application or library| |program|
|
||||
|classModifier|Class modifiers such as abstract or partial| ||
|
||||
|operationModifier|Operation modifiers such as virtual or abstract.| |virtual|
|
||||
|generateBody|Generates method body.| |true|
|
||||
|buildTarget|Target the build for a program or library.| |program|
|
||||
|
||||
@@ -22,6 +22,7 @@ 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|
|
||||
|
||||
@@ -22,6 +22,7 @@ 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|
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>4.0.0-beta3</version>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
openApiGeneratorVersion=4.0.0-beta3
|
||||
openApiGeneratorVersion=4.0.0-SNAPSHOT
|
||||
|
||||
# BEGIN placeholders
|
||||
# these are just placeholders to allow contributors to build directly
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>4.0.0-beta3</version>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>4.0.0-beta3</version>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>openapi-generator-maven-plugin</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>4.0.0-beta3</version>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<artifactId>openapi-generator-online</artifactId>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<parent>
|
||||
<groupId>org.openapitools</groupId>
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<version>4.0.0-beta3</version>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<relativePath>../..</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -28,7 +28,6 @@ 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) {
|
||||
@@ -74,18 +73,6 @@ 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>();
|
||||
|
||||
@@ -191,6 +191,9 @@ 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.";
|
||||
|
||||
|
||||
@@ -408,8 +408,8 @@ public class InlineModelResolver {
|
||||
|
||||
private String uniqueName(String key) {
|
||||
if (key == null) {
|
||||
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.");
|
||||
key = "NULL_UNIQUE_NAME";
|
||||
LOGGER.warn("null key found. Default to NULL_UNIQUE_NAME");
|
||||
}
|
||||
int count = 0;
|
||||
boolean done = false;
|
||||
|
||||
@@ -232,8 +232,16 @@ public class ExampleGenerator {
|
||||
Schema innerType = ((ArraySchema) property).getItems();
|
||||
if (innerType != null) {
|
||||
int arrayLength = null == ((ArraySchema) property).getMaxItems() ? 2 : ((ArraySchema) property).getMaxItems();
|
||||
// avoid memory issues by limiting to max. 5 items
|
||||
arrayLength = Math.min(arrayLength, 5);
|
||||
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;
|
||||
}
|
||||
Object[] objectProperties = new Object[arrayLength];
|
||||
Object objProperty = resolvePropertyToExample(propertyName, mediaType, innerType, processedModels);
|
||||
for (int i = 0; i < arrayLength; i++) {
|
||||
|
||||
@@ -39,6 +39,7 @@ 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;
|
||||
@@ -196,6 +197,10 @@ 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) {
|
||||
@@ -334,6 +339,12 @@ 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 {
|
||||
|
||||
@@ -20,7 +20,10 @@ 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.*;
|
||||
import org.openapitools.codegen.CodegenConstants;
|
||||
import org.openapitools.codegen.CodegenOperation;
|
||||
import org.openapitools.codegen.CodegenType;
|
||||
import org.openapitools.codegen.SupportingFile;
|
||||
import org.openapitools.codegen.utils.URLPathUtils;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
@@ -45,7 +48,6 @@ 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) + "}";
|
||||
|
||||
@@ -55,13 +57,13 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
private boolean useSwashbuckle = true;
|
||||
protected int serverPort = 8080;
|
||||
protected String serverHost = "0.0.0.0";
|
||||
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");
|
||||
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 boolean generateBody = true;
|
||||
private CliOption buildTarget = new CliOption("buildTarget", "Target to build an application or library");
|
||||
private String buildTarget = "program";
|
||||
private String projectSdk = SDK_WEB;
|
||||
private String compatibilityVersion = "Version_2_1";
|
||||
|
||||
public AspNetCoreServerCodegen() {
|
||||
super();
|
||||
@@ -130,14 +132,9 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
CodegenConstants.SOURCE_FOLDER_DESC,
|
||||
sourceFolder);
|
||||
|
||||
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());
|
||||
addOption(ASPNET_CORE_VERSION,
|
||||
"ASP.NET Core version: 2.1 (default), 2.0 (deprecated)",
|
||||
aspnetCoreVersion);
|
||||
|
||||
// CLI Switches
|
||||
addSwitch(CodegenConstants.SORT_PARAMS_BY_REQUIRED_FLAG,
|
||||
@@ -160,28 +157,22 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
"Uses the Swashbuckle.AspNetCore NuGet package for documentation.",
|
||||
useSwashbuckle);
|
||||
|
||||
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(CLASS_MODIFIER,
|
||||
"Class modifiers such as abstract or partial",
|
||||
classModifier);
|
||||
|
||||
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());
|
||||
addOption(OPERATION_MODIFIER,
|
||||
"Operation modifiers such as virtual or abstract.",
|
||||
operationModifier);
|
||||
|
||||
addSwitch(GENERATE_BODY,
|
||||
"Generates method body.",
|
||||
generateBody);
|
||||
|
||||
addOption(BUILD_TARGET,
|
||||
"Target the build for a program or library.",
|
||||
buildTarget);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -223,15 +214,53 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
additionalProperties.put(USE_SWASHBUCKLE, useSwashbuckle);
|
||||
}
|
||||
|
||||
|
||||
// CHeck for the modifiers etc.
|
||||
// The order of the checks is important.
|
||||
isLibrary = setBuildTarget();
|
||||
setClassModifier();
|
||||
setOperationModifier();
|
||||
|
||||
// determine the ASP.NET core version setting
|
||||
if (additionalProperties.containsKey(ASPNET_CORE_VERSION)) {
|
||||
setAspnetCoreVersion((String) additionalProperties.get(ASPNET_CORE_VERSION));
|
||||
}
|
||||
|
||||
// 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));
|
||||
@@ -241,8 +270,17 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
||||
|
||||
String packageFolder = sourceFolder + File.separator + packageName;
|
||||
|
||||
// determine the ASP.NET core version setting
|
||||
setAspnetCoreVersion(packageFolder);
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
supportingFiles.add(new SupportingFile("build.sh.mustache", "", "build.sh"));
|
||||
supportingFiles.add(new SupportingFile("build.bat.mustache", "", "build.bat"));
|
||||
@@ -269,6 +307,26 @@ 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) {
|
||||
@@ -283,6 +341,10 @@ 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";
|
||||
@@ -326,7 +388,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());
|
||||
@@ -339,72 +401,4 @@ 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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -170,6 +170,10 @@ 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);
|
||||
@@ -326,6 +330,9 @@ 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 {
|
||||
|
||||
@@ -184,6 +184,10 @@ 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
|
||||
@@ -506,6 +510,8 @@ 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);
|
||||
|
||||
@@ -0,0 +1,153 @@
|
||||
/*
|
||||
* Copyright 2018 OpenAPI-Generator Contributors (https://openapi-generator.tech)
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.openapitools.codegen.languages;
|
||||
|
||||
import io.swagger.v3.oas.models.OpenAPI;
|
||||
import io.swagger.v3.oas.models.info.Info;
|
||||
import org.openapitools.codegen.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class NodeJSFastifyServerCodegen extends DefaultCodegen implements CodegenConfig {
|
||||
|
||||
private static final Logger LOGGER = LoggerFactory.getLogger(NodeJSServerCodegen.class);
|
||||
|
||||
protected String projectName = "openapi-server";
|
||||
|
||||
public NodeJSFastifyServerCodegen() {
|
||||
super();
|
||||
|
||||
outputFolder = "generated-code/nodejs-fastify";
|
||||
|
||||
modelTemplateFiles.clear();
|
||||
apiTemplateFiles.clear();
|
||||
|
||||
embeddedTemplateDir = templateDir = "nodejs-fastify";
|
||||
|
||||
setReservedWordsLowerCase(
|
||||
Arrays.asList(
|
||||
"break", "case", "class", "catch", "const", "continue", "debugger",
|
||||
"default", "delete", "do", "else", "export", "extends", "finally",
|
||||
"for", "function", "if", "import", "in", "instanceof", "let", "new",
|
||||
"return", "super", "switch", "this", "throw", "try", "typeof", "var",
|
||||
"void", "while", "with", "yield")
|
||||
);
|
||||
|
||||
supportingFiles.add(new SupportingFile("index.mustache", "", "index.js"));
|
||||
supportingFiles.add(new SupportingFile("readme.mustache", "", "README.md"));
|
||||
supportingFiles.add(new SupportingFile("openapi.mustache", "", "openapi.json"));
|
||||
supportingFiles.add(new SupportingFile("package.mustache", "", "package.json"));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures the type of generator.
|
||||
*
|
||||
* @return the CodegenType for this generator
|
||||
* @see org.openapitools.codegen.CodegenType
|
||||
*/
|
||||
@Override
|
||||
public CodegenType getTag() {
|
||||
return CodegenType.SERVER;
|
||||
}
|
||||
|
||||
/**
|
||||
* Configures a friendly name for the generator. This will be used by the generator
|
||||
* to select the library with the -g flag.
|
||||
*
|
||||
* @return the friendly name for the generator
|
||||
*/
|
||||
@Override
|
||||
public String getName() {
|
||||
return "nodejs-fastify-server";
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns human-friendly help for the generator. Provide the consumer with help
|
||||
* tips, parameters here
|
||||
*
|
||||
* @return A string value for the help message
|
||||
*/
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a NodeJS Fastify server library";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
writeOptional(outputFolder, new SupportingFile("service.mustache", "", "service.js"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> postProcessSupportingFileData(Map<String, Object> objs) {
|
||||
generateJSONSpecFile(objs);
|
||||
|
||||
return super.postProcessSupportingFileData(objs);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void preprocessOpenAPI(OpenAPI openAPI) {
|
||||
|
||||
if (openAPI.getInfo() != null) {
|
||||
Info info = openAPI.getInfo();
|
||||
if (info.getTitle() != null) {
|
||||
// when info.title is defined, use it for projectName
|
||||
// used in package.json
|
||||
projectName = info.getTitle()
|
||||
.replaceAll("[^a-zA-Z0-9]", "-")
|
||||
.replaceAll("^[-]*", "")
|
||||
.replaceAll("[-]*$", "")
|
||||
.replaceAll("[-]{2,}", "-")
|
||||
.toLowerCase(Locale.ROOT);
|
||||
}
|
||||
}
|
||||
|
||||
this.additionalProperties.put("projectName", projectName);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Escapes a reserved word as defined in the `reservedWords` array. Handle escaping
|
||||
* those terms here. This logic is only called if a variable matches the reserved words
|
||||
*
|
||||
* @return the escaped term
|
||||
*/
|
||||
@Override
|
||||
public String escapeReservedWord(String name) {
|
||||
if (this.reservedWordsMappings().containsKey(name)) {
|
||||
return this.reservedWordsMappings().get(name);
|
||||
}
|
||||
return "_" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeUnsafeCharacters(String input) {
|
||||
return input.replace("*/", "*_/").replace("/*", "/_*");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String escapeQuotationMark(String input) {
|
||||
// remove " to avoid code injection
|
||||
return input.replace("\"", "");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -120,7 +120,7 @@ public class OAuth implements RequestInterceptor {
|
||||
|
||||
public synchronized void setAccessToken(String accessToken, Long expiresIn) {
|
||||
this.accessToken = accessToken;
|
||||
this.expirationTimeMillis = expiresIn == null ? null : System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
|
||||
this.expirationTimeMillis = System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
|
||||
}
|
||||
|
||||
public TokenRequestBuilder getTokenRequestBuilder() {
|
||||
|
||||
@@ -61,6 +61,7 @@ org.openapitools.codegen.languages.JMeterClientCodegen
|
||||
org.openapitools.codegen.languages.LuaClientCodegen
|
||||
org.openapitools.codegen.languages.MysqlSchemaCodegen
|
||||
org.openapitools.codegen.languages.NodeJSServerCodegen
|
||||
org.openapitools.codegen.languages.NodeJSFastifyServerCodegen
|
||||
org.openapitools.codegen.languages.ObjcClientCodegen
|
||||
org.openapitools.codegen.languages.OpenAPIGenerator
|
||||
org.openapitools.codegen.languages.OpenAPIYamlGenerator
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM microsoft/dotnet:{{aspnetCoreVersion}}-sdk AS build-env
|
||||
FROM microsoft/dotnet:2.1-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:{{aspnetCoreVersion}}-aspnetcore-runtime
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime
|
||||
WORKDIR /app
|
||||
COPY --from=build-env /app/out .
|
||||
ENTRYPOINT ["dotnet", "{{packageName}}.dll"]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<Description>{{packageName}}</Description>
|
||||
<Copyright>{{packageName}}</Copyright>
|
||||
<TargetFramework>netcoreapp{{aspnetCoreVersion}}</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||
<AssemblyName>{{packageName}}</AssemblyName>
|
||||
|
||||
@@ -43,9 +43,7 @@ namespace {{packageName}}
|
||||
// Add framework services.
|
||||
services
|
||||
.AddMvc()
|
||||
{{#compatibilityVersion}}
|
||||
.SetCompatibilityVersion(CompatibilityVersion.{{compatibilityVersion}})
|
||||
{{/compatibilityVersion}}
|
||||
.SetCompatibilityVersion (CompatibilityVersion.Version_2_1)
|
||||
.AddJsonOptions(opts =>
|
||||
{
|
||||
opts.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
|
||||
@@ -109,7 +107,7 @@ namespace {{packageName}}
|
||||
// c.SwaggerEndpoint("/openapi-original.json", "{{#appName}}{{{appName}}}{{/appName}}{{^appName}}{{packageName}}{{/appName}} Original");
|
||||
}){{/useSwashbuckle}};
|
||||
|
||||
if (env.IsDevelopment())
|
||||
if (env.IsDevelopment())
|
||||
{
|
||||
app.UseDeveloperExceptionPage();
|
||||
}
|
||||
|
||||
@@ -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}}){{^generateBody}};{{/generateBody}}
|
||||
public {{operationModifier}} IActionResult {{operationId}}({{#allParams}}{{>pathParam}}{{>queryParam}}{{>bodyParam}}{{>formParam}}{{>headerParam}}{{#hasMore}}, {{/hasMore}}{{/allParams}})
|
||||
{{#generateBody}}
|
||||
{ {{#responses}}
|
||||
{{#dataType}}
|
||||
@@ -51,6 +51,9 @@ namespace {{packageName}}.Controllers
|
||||
throw new NotImplementedException();{{/returnType}}
|
||||
}
|
||||
{{/generateBody}}
|
||||
{{^generateBody}}
|
||||
;
|
||||
{{/generateBody}}
|
||||
{{/operation}}
|
||||
}
|
||||
{{/operations}}
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
{{#description}}
|
||||
/// <value>{{description}}</value>
|
||||
{{/description}}
|
||||
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})]
|
||||
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/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}}false{{/isNullable}})]{{#isDate}}
|
||||
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/isNullable}})]{{#isDate}}
|
||||
[JsonConverter(typeof(OpenAPIDateConverter))]{{/isDate}}
|
||||
public {{{dataType}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; }
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
{{#description}}
|
||||
/// <value>{{description}}</value>
|
||||
{{/description}}
|
||||
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}false{{/isNullable}})]
|
||||
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/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}}false{{/isNullable}})]{{#isDate}}
|
||||
[DataMember(Name="{{baseName}}", EmitDefaultValue={{#isNullable}}true{{/isNullable}}{{^isNullable}}{{emitDefaultValue}}{{/isNullable}})]{{#isDate}}
|
||||
[JsonConverter(typeof(OpenAPIDateConverter))]{{/isDate}}
|
||||
public {{{dataType}}} {{name}} { get; {{#isReadOnly}}private {{/isReadOnly}}set; }
|
||||
{{/isEnum}}
|
||||
|
||||
15
modules/openapi-generator/src/main/resources/nodejs-fastify-server/README.mustache
vendored
Normal file
15
modules/openapi-generator/src/main/resources/nodejs-fastify-server/README.mustache
vendored
Normal file
@@ -0,0 +1,15 @@
|
||||
# {{^projectName}}NodeJS Fastify Server{{/projectName}}{{{projectName}}}
|
||||
|
||||
## OpenAPI
|
||||
|
||||
- [openapi.json](openapi.json)
|
||||
|
||||
## Usage
|
||||
|
||||
In this directory use:
|
||||
|
||||
+ "npm install" to install its dependencies
|
||||
+ "npm start" to start fastify using fastify-cli
|
||||
+ "npm run dev" to start fastify using fastify-cli with logging to the console
|
||||
+ "npm test" to run tests
|
||||
|
||||
21
modules/openapi-generator/src/main/resources/nodejs-fastify-server/controller.mustache
vendored
Normal file
21
modules/openapi-generator/src/main/resources/nodejs-fastify-server/controller.mustache
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
'use strict';
|
||||
|
||||
var utils = require('../utils/writer.js');
|
||||
{{#operations}}
|
||||
var {{classname}} = require('../{{implFolder}}/{{classname}}Service');
|
||||
{{#operation}}
|
||||
|
||||
module.exports.{{nickname}} = function {{nickname}} (req, res, next) {
|
||||
{{#allParams}}
|
||||
var {{paramName}} = req.swagger.params['{{baseName}}'].value;
|
||||
{{/allParams}}
|
||||
{{classname}}.{{nickname}}({{#allParams}}{{paramName}}{{#hasMore}},{{/hasMore}}{{/allParams}})
|
||||
.then(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
})
|
||||
.catch(function (response) {
|
||||
utils.writeJson(res, response);
|
||||
});
|
||||
};
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
44
modules/openapi-generator/src/main/resources/nodejs-fastify-server/index-gcf.mustache
vendored
Normal file
44
modules/openapi-generator/src/main/resources/nodejs-fastify-server/index-gcf.mustache
vendored
Normal file
@@ -0,0 +1,44 @@
|
||||
'use strict';
|
||||
|
||||
var swaggerTools = require('swagger-tools');
|
||||
var jsyaml = require('js-yaml');
|
||||
var fs = require('fs');
|
||||
|
||||
// swaggerRouter configuration
|
||||
var options = {
|
||||
controllers: './controllers',
|
||||
useStubs: false
|
||||
};
|
||||
|
||||
// The Swagger document (require it, build it programmatically, fetch it from a URL, ...)
|
||||
var spec = fs.readFileSync('./api/openapi.yaml', 'utf8');
|
||||
var swaggerDoc = jsyaml.safeLoad(spec);
|
||||
|
||||
function toPromise(f, req, res) {
|
||||
return new Promise(function(resolve, reject) {
|
||||
f(req, res, function(err) {
|
||||
if (err) {
|
||||
reject(err);
|
||||
} else {
|
||||
resolve();
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
exports.{{exportedName}} = function(req, res) {
|
||||
swaggerTools.initializeMiddleware(swaggerDoc, function(middleware) {
|
||||
var metadata = middleware.swaggerMetadata();
|
||||
var validator = middleware.swaggerValidator();
|
||||
var router = middleware.swaggerRouter(options);
|
||||
req.url = swaggerDoc.basePath + req.url;
|
||||
toPromise(metadata, req, res).then(function() {
|
||||
return toPromise(validator, req, res);
|
||||
}).then(function() {
|
||||
return toPromise(router, req, res);
|
||||
}).catch(function(err) {
|
||||
console.error(err);
|
||||
res.status(res.statusCode || 400).send(err);
|
||||
});
|
||||
});
|
||||
};
|
||||
10
modules/openapi-generator/src/main/resources/nodejs-fastify-server/index.mustache
vendored
Normal file
10
modules/openapi-generator/src/main/resources/nodejs-fastify-server/index.mustache
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
const openapiGlue = require("../../index.js");
|
||||
|
||||
const options = {
|
||||
specification: `${__dirname}/openapi.json`,
|
||||
service: `${__dirname}/service.js`
|
||||
};
|
||||
|
||||
module.exports = async function(fastify, opts) {
|
||||
fastify.register(openapiGlue, options);
|
||||
};
|
||||
1
modules/openapi-generator/src/main/resources/nodejs-fastify-server/openapi.mustache
vendored
Normal file
1
modules/openapi-generator/src/main/resources/nodejs-fastify-server/openapi.mustache
vendored
Normal file
@@ -0,0 +1 @@
|
||||
{{{openapi-json}}}
|
||||
25
modules/openapi-generator/src/main/resources/nodejs-fastify-server/package.mustache
vendored
Normal file
25
modules/openapi-generator/src/main/resources/nodejs-fastify-server/package.mustache
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "{{projectName}}",
|
||||
"version": "{{appVersion}}",
|
||||
"description": "{{{appDescription}}}",
|
||||
"scripts": {
|
||||
"start": "fastify start index.js",
|
||||
"test": "tap test/test-*.js",
|
||||
"dev": "fastify start -l info -P index.js"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"keywords": [
|
||||
"openapi", "openapi-generator"
|
||||
],
|
||||
"license": "Unlicense",
|
||||
"dependencies": {
|
||||
"fastify-plugin": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"fastify": "^2.0.0",
|
||||
"fastify-cli": "^1.0.0",
|
||||
"tap": "^12.5.3"
|
||||
}
|
||||
}
|
||||
50
modules/openapi-generator/src/main/resources/nodejs-fastify-server/service.mustache
vendored
Normal file
50
modules/openapi-generator/src/main/resources/nodejs-fastify-server/service.mustache
vendored
Normal file
@@ -0,0 +1,50 @@
|
||||
class Service {
|
||||
constructor() {}
|
||||
|
||||
{{#apiInfo}}
|
||||
{{#apis}}
|
||||
{{#operations}}
|
||||
{{#operation}}
|
||||
/**
|
||||
{{#summary}}
|
||||
* {{{summary}}}
|
||||
{{/summary}}
|
||||
{{#notes}}
|
||||
* {{{notes}}}
|
||||
{{/notes}}
|
||||
*
|
||||
{{#allParams}}
|
||||
* {{paramName}} {{{dataType}}} {{{description}}}{{^required}} (optional){{/required}}
|
||||
{{/allParams}}
|
||||
{{^returnType}}
|
||||
* no response value expected for this operation
|
||||
{{/returnType}}
|
||||
{{#returnType}}
|
||||
* returns {{{returnType}}}
|
||||
{{/returnType}}
|
||||
**/
|
||||
async {{{operationId}}}(req, resp) {
|
||||
console.log("{{{operationId}}}");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
{{#returnType}}
|
||||
{{#examples}}
|
||||
/*return {{{example}}};
|
||||
*/
|
||||
|
||||
{{/examples}}
|
||||
return {};
|
||||
{{/returnType}}
|
||||
{{^returnType}}
|
||||
return;
|
||||
{{/returnType}}
|
||||
};
|
||||
}
|
||||
|
||||
{{/operation}}
|
||||
{{/operations}}
|
||||
{{/apis}}
|
||||
{{/apiInfo}}
|
||||
|
||||
module.exports = config => new Service();
|
||||
@@ -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.headers.Header;
|
||||
import io.swagger.v3.oas.models.media.*;
|
||||
import io.swagger.v3.oas.models.headers.Header;
|
||||
import io.swagger.v3.oas.models.parameters.QueryParameter;
|
||||
import io.swagger.v3.oas.models.parameters.RequestBody;
|
||||
import io.swagger.v3.oas.models.responses.ApiResponse;
|
||||
|
||||
@@ -9,13 +9,15 @@ 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 {
|
||||
|
||||
|
||||
@@ -378,7 +378,7 @@ public class InlineModelResolverTest {
|
||||
|
||||
ArraySchema requestBody = (ArraySchema) mediaType.getSchema();
|
||||
assertNotNull(requestBody.getItems().get$ref());
|
||||
assertEquals("#/components/schemas/InlineObject", requestBody.getItems().get$ref());
|
||||
assertEquals("#/components/schemas/NULL_UNIQUE_NAME", requestBody.getItems().get$ref());
|
||||
|
||||
Schema items = ModelUtils.getReferencedSchema(openAPI, ((ArraySchema) mediaType.getSchema()).getItems());
|
||||
assertTrue(items.getProperties().get("street") instanceof StringSchema);
|
||||
|
||||
@@ -264,10 +264,7 @@ public class AbstractJavaCodegenTest {
|
||||
/**
|
||||
* Gets artifact version.
|
||||
* Only for testing purposes.
|
||||
* @return version
|
||||
*/
|
||||
public String getArtifactVersion() {
|
||||
return this.artifactVersion;
|
||||
}
|
||||
public String getArtifactVersion () { return this.artifactVersion; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,6 +28,7 @@ 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;
|
||||
@@ -36,10 +37,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() {
|
||||
@@ -1214,9 +1215,8 @@ public class JavaModelTest {
|
||||
public void generateModel() throws Exception {
|
||||
String inputSpec = "src/test/resources/3_0/petstore.json";
|
||||
|
||||
final File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
|
||||
folder.create();
|
||||
final File output = folder.getRoot();
|
||||
Assert.assertTrue(new File(inputSpec).exists());
|
||||
|
||||
final CodegenConfigurator configurator = new CodegenConfigurator()
|
||||
@@ -1232,14 +1232,15 @@ 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";
|
||||
|
||||
final File output = Files.createTempDirectory("test").toFile();
|
||||
output.deleteOnExit();
|
||||
folder.create();
|
||||
final File output = folder.getRoot();
|
||||
Assert.assertTrue(new File(inputSpec).exists());
|
||||
|
||||
JavaClientCodegen config = new org.openapitools.codegen.languages.JavaClientCodegen();
|
||||
@@ -1257,5 +1258,6 @@ public class JavaModelTest {
|
||||
|
||||
File orderFile = new File(output, "src/main/java/org/openapitools/client/api/DefaultApi.java");
|
||||
Assert.assertTrue(orderFile.exists());
|
||||
folder.delete();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,9 @@
|
||||
package org.openapitools.codegen.java.jaxrs;
|
||||
|
||||
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 static org.testng.Assert.assertEquals;
|
||||
import static org.testng.Assert.assertNotNull;
|
||||
import static org.testng.Assert.assertNull;
|
||||
import static org.testng.Assert.assertTrue;
|
||||
|
||||
import java.io.File;
|
||||
import java.nio.file.Files;
|
||||
@@ -19,7 +11,36 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static org.testng.Assert.*;
|
||||
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;
|
||||
|
||||
public class JavaJAXRSCXFExtServerCodegenTest {
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
@@ -1,16 +1,18 @@
|
||||
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}.
|
||||
*
|
||||
@@ -20,7 +22,7 @@ public class JavaJAXRSSpecServerCodegenTest {
|
||||
|
||||
private JavaJAXRSSpecServerCodegen instance;
|
||||
|
||||
@BeforeMethod
|
||||
@Before
|
||||
public void before() {
|
||||
instance = new JavaJAXRSSpecServerCodegen();
|
||||
}
|
||||
@@ -38,9 +40,9 @@ public class JavaJAXRSSpecServerCodegenTest {
|
||||
|
||||
instance.addOperationToGroup("Primaryresource", "/", operation, codegenOperation, operationList);
|
||||
|
||||
Assert.assertEquals(operationList.size(), 1);
|
||||
Assert.assertTrue(operationList.containsKey(""));
|
||||
Assert.assertEquals(codegenOperation.baseName, "Primaryresource");
|
||||
assertThat(operationList.size(), is(1));
|
||||
assertThat(operationList.containsKey(""), is(true));
|
||||
assertThat(codegenOperation.baseName, is("Primaryresource"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -56,9 +58,9 @@ public class JavaJAXRSSpecServerCodegenTest {
|
||||
|
||||
instance.addOperationToGroup("Primaryresource", "/{uuid}", operation, codegenOperation, operationList);
|
||||
|
||||
Assert.assertEquals(operationList.size(), 1);
|
||||
Assert.assertTrue(operationList.containsKey(""));
|
||||
Assert.assertEquals(codegenOperation.baseName, "Primaryresource");
|
||||
assertThat(operationList.size(), is(1));
|
||||
assertThat(operationList.containsKey(""), is(true));
|
||||
assertThat(codegenOperation.baseName, is("Primaryresource"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -75,9 +77,9 @@ public class JavaJAXRSSpecServerCodegenTest {
|
||||
|
||||
instance.addOperationToGroup("Default", "/subresource", operation, codegenOperation, operationList);
|
||||
|
||||
Assert.assertEquals(codegenOperation.baseName, "subresource");
|
||||
Assert.assertEquals(operationList.size(), 1);
|
||||
Assert.assertTrue(operationList.containsKey("subresource"));
|
||||
assertThat(codegenOperation.baseName, is("subresource"));
|
||||
assertThat(operationList.size(), is(1));
|
||||
assertThat(operationList.containsKey("subresource"), is(true));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +88,7 @@ public class JavaJAXRSSpecServerCodegenTest {
|
||||
@Test
|
||||
public void testToApiNameForSubresource() {
|
||||
final String subresource = instance.toApiName("subresource");
|
||||
Assert.assertEquals(subresource, "SubresourceApi");
|
||||
assertThat(subresource, is("SubresourceApi"));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -101,6 +103,6 @@ public class JavaJAXRSSpecServerCodegenTest {
|
||||
instance.addOperationToGroup("Primaryresource", "/", operation, codegenOperation, operationList);
|
||||
|
||||
final String subresource = instance.toApiName("");
|
||||
Assert.assertEquals(subresource, "PrimaryresourceApi");
|
||||
assertThat(subresource, is("PrimaryresourceApi"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,14 +21,16 @@ 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;
|
||||
@@ -42,12 +44,21 @@ 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 = Files.createTempDirectory("test").toFile();
|
||||
output.mkdirs();
|
||||
output.deleteOnExit();
|
||||
final File output = folder.getRoot();
|
||||
|
||||
final OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/2_0/pathWithHtmlEntity.yaml");
|
||||
CodegenConfig codegenConfig = new RubyClientCodegen();
|
||||
@@ -109,9 +120,7 @@ public class RubyClientCodegenTest {
|
||||
|
||||
@Test
|
||||
public void testBooleanDefaultValue() throws Exception {
|
||||
final File output = Files.createTempDirectory("test").toFile();
|
||||
output.mkdirs();
|
||||
output.deleteOnExit();
|
||||
final File output = folder.getRoot();
|
||||
|
||||
final OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/2_0/npe1.yaml");
|
||||
CodegenConfig codegenConfig = new RubyClientCodegen();
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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 {
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ public class TypeScriptNodeClientCodegenTest {
|
||||
codegen.additionalProperties().put("npmVersion", "1.0.0-SNAPSHOT");
|
||||
codegen.processOpts();
|
||||
|
||||
Assert.assertTrue(codegen.getNpmVersion().matches("^1.0.0-SNAPSHOT.[0-9]{12}$"));
|
||||
org.junit.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();
|
||||
|
||||
Assert.assertTrue(codegen.getNpmVersion().matches("^3.0.0-M1-SNAPSHOT.[0-9]{12}$"));
|
||||
org.junit.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();
|
||||
|
||||
Assert.assertTrue(codegen.getNpmVersion().matches("^1.0.0-SNAPSHOT$"));
|
||||
org.junit.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();
|
||||
|
||||
Assert.assertTrue(codegen.getNpmVersion().matches("^3.0.0-M1$"));
|
||||
org.junit.Assert.assertTrue(codegen.getNpmVersion().matches("^3.0.0-M1$"));
|
||||
|
||||
}
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,9 @@ package org.openapitools.codegen.utils;
|
||||
import org.testng.Assert;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
import static org.openapitools.codegen.utils.StringUtils.*;
|
||||
import static org.openapitools.codegen.utils.StringUtils.camelize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.dashize;
|
||||
import static org.openapitools.codegen.utils.StringUtils.underscore;
|
||||
|
||||
public class StringUtilsTest {
|
||||
// we'll assume that <i>underscore</i> (Twitter elephant bird) works fine
|
||||
|
||||
22
pom.xml
22
pom.xml
@@ -9,7 +9,7 @@
|
||||
<artifactId>openapi-generator-project</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>openapi-generator-project</name>
|
||||
<version>4.0.0-beta3</version>
|
||||
<version>4.0.0-SNAPSHOT</version>
|
||||
<url>https://github.com/openapitools/openapi-generator</url>
|
||||
<scm>
|
||||
<connection>scm:git:git@github.com:openapitools/openapi-generator.git</connection>
|
||||
@@ -157,11 +157,23 @@
|
||||
<version>${surefire-version}</version>
|
||||
<configuration>
|
||||
<useSystemClassLoader>false</useSystemClassLoader>
|
||||
<junitArtifactName>none:none</junitArtifactName>
|
||||
<testNGArtifactName>org.testng:testng</testNGArtifactName>
|
||||
<testNGArtifactName>none:none</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>
|
||||
@@ -1371,8 +1383,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.14.3</testng-version>
|
||||
<surefire-version>2.22.1</surefire-version>
|
||||
<testng-version>6.9.6</testng-version>
|
||||
<surefire-version>2.22.0</surefire-version>
|
||||
<jmockit-version>1.43</jmockit-version>
|
||||
<reflections-version>0.9.10</reflections-version>
|
||||
</properties>
|
||||
|
||||
@@ -120,8 +120,7 @@ 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
|
||||
@@ -333,8 +332,7 @@ 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
|
||||
@@ -354,8 +352,7 @@ 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
|
||||
@@ -1075,8 +1072,7 @@ 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:
|
||||
|
||||
@@ -120,8 +120,7 @@ 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
|
||||
@@ -333,8 +332,7 @@ 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
|
||||
@@ -354,8 +352,7 @@ 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
|
||||
@@ -1075,8 +1072,7 @@ 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:
|
||||
|
||||
@@ -112,7 +112,7 @@ public class OAuth implements RequestInterceptor {
|
||||
|
||||
public synchronized void setAccessToken(String accessToken, Long expiresIn) {
|
||||
this.accessToken = accessToken;
|
||||
this.expirationTimeMillis = expiresIn == null ? null : System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
|
||||
this.expirationTimeMillis = System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
|
||||
}
|
||||
|
||||
public TokenRequestBuilder getTokenRequestBuilder() {
|
||||
|
||||
@@ -113,7 +113,7 @@ public class OAuth implements RequestInterceptor {
|
||||
|
||||
public synchronized void setAccessToken(String accessToken, Long expiresIn) {
|
||||
this.accessToken = accessToken;
|
||||
this.expirationTimeMillis = expiresIn == null ? null : System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
|
||||
this.expirationTimeMillis = System.currentTimeMillis() + expiresIn * MILLIS_PER_SECOND;
|
||||
}
|
||||
|
||||
public TokenRequestBuilder getTokenRequestBuilder() {
|
||||
|
||||
@@ -126,7 +126,7 @@
|
||||
</dependencies>
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<openapi-generator-version>4.0.0-beta3</openapi-generator-version>
|
||||
<openapi-generator-version>4.0.0-SNAPSHOT</openapi-generator-version>
|
||||
<maven-plugin-version>1.0.0</maven-plugin-version>
|
||||
<junit-version>4.8.1</junit-version>
|
||||
</properties>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
FROM microsoft/dotnet:2.2-sdk AS build-env
|
||||
FROM microsoft/dotnet:2.1-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.2-aspnetcore-runtime
|
||||
FROM microsoft/dotnet:2.1-aspnetcore-runtime
|
||||
WORKDIR /app
|
||||
COPY --from=build-env /app/out .
|
||||
ENTRYPOINT ["dotnet", "Org.OpenAPITools.dll"]
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
<PropertyGroup>
|
||||
<Description>Org.OpenAPITools</Description>
|
||||
<Copyright>Org.OpenAPITools</Copyright>
|
||||
<TargetFramework>netcoreapp2.2</TargetFramework>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||
<AssemblyName>Org.OpenAPITools</AssemblyName>
|
||||
|
||||
@@ -52,7 +52,7 @@ namespace Org.OpenAPITools
|
||||
// Add framework services.
|
||||
services
|
||||
.AddMvc()
|
||||
.SetCompatibilityVersion(CompatibilityVersion.Version_2_2)
|
||||
.SetCompatibilityVersion (CompatibilityVersion.Version_2_1)
|
||||
.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();
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
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
|
||||
@@ -119,8 +118,7 @@ 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,8 +330,7 @@ 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
|
||||
@@ -353,8 +350,7 @@ 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
|
||||
|
||||
@@ -126,8 +126,7 @@ 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
|
||||
@@ -353,8 +352,7 @@ 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
|
||||
@@ -376,8 +374,7 @@ 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
|
||||
@@ -1143,8 +1140,7 @@ 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:
|
||||
|
||||
@@ -126,8 +126,7 @@ 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
|
||||
@@ -353,8 +352,7 @@ 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
|
||||
@@ -376,8 +374,7 @@ 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
|
||||
@@ -1143,8 +1140,7 @@ 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:
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
@@ -0,0 +1 @@
|
||||
4.0.0-SNAPSHOT
|
||||
15
samples/server/petstore/nodejs-fastify-server/README.md
Normal file
15
samples/server/petstore/nodejs-fastify-server/README.md
Normal file
@@ -0,0 +1,15 @@
|
||||
# openapi-petstore
|
||||
|
||||
## OpenAPI
|
||||
|
||||
- [openapi.json](openapi.json)
|
||||
|
||||
## Usage
|
||||
|
||||
In this directory use:
|
||||
|
||||
+ "npm install" to install its dependencies
|
||||
+ "npm start" to start fastify using fastify-cli
|
||||
+ "npm run dev" to start fastify using fastify-cli with logging to the console
|
||||
+ "npm test" to run tests
|
||||
|
||||
10
samples/server/petstore/nodejs-fastify-server/index.js
Normal file
10
samples/server/petstore/nodejs-fastify-server/index.js
Normal file
@@ -0,0 +1,10 @@
|
||||
const openapiGlue = require("../../index.js");
|
||||
|
||||
const options = {
|
||||
specification: `${__dirname}/openapi.json`,
|
||||
service: `${__dirname}/service.js`
|
||||
};
|
||||
|
||||
module.exports = async function(fastify, opts) {
|
||||
fastify.register(openapiGlue, options);
|
||||
};
|
||||
1012
samples/server/petstore/nodejs-fastify-server/openapi.json
Normal file
1012
samples/server/petstore/nodejs-fastify-server/openapi.json
Normal file
File diff suppressed because it is too large
Load Diff
25
samples/server/petstore/nodejs-fastify-server/package.json
Normal file
25
samples/server/petstore/nodejs-fastify-server/package.json
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"name": "openapi-petstore",
|
||||
"version": "1.0.0",
|
||||
"description": "This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.",
|
||||
"scripts": {
|
||||
"start": "fastify start index.js",
|
||||
"test": "tap test/test-*.js",
|
||||
"dev": "fastify start -l info -P index.js"
|
||||
},
|
||||
"directories": {
|
||||
"test": "test"
|
||||
},
|
||||
"keywords": [
|
||||
"openapi", "openapi-generator"
|
||||
],
|
||||
"license": "Unlicense",
|
||||
"dependencies": {
|
||||
"fastify-plugin": "^1.0.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"fastify": "^2.0.0",
|
||||
"fastify-cli": "^1.0.0",
|
||||
"tap": "^12.5.3"
|
||||
}
|
||||
}
|
||||
483
samples/server/petstore/nodejs-fastify-server/service.js
Normal file
483
samples/server/petstore/nodejs-fastify-server/service.js
Normal file
@@ -0,0 +1,483 @@
|
||||
class Service {
|
||||
constructor() {}
|
||||
|
||||
/**
|
||||
* Add a new pet to the store
|
||||
*
|
||||
* body Pet Pet object that needs to be added to the store
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
async addPet(req, resp) {
|
||||
console.log("addPet");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes a pet
|
||||
*
|
||||
* petId Long Pet id to delete
|
||||
* apiKey String (optional)
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
async deletePet(req, resp) {
|
||||
console.log("deletePet");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by status
|
||||
* Multiple status values can be provided with comma separated strings
|
||||
*
|
||||
* status List Status values that need to be considered for filter
|
||||
* returns List
|
||||
**/
|
||||
async findPetsByStatus(req, resp) {
|
||||
console.log("findPetsByStatus");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
/*return {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
};
|
||||
*/
|
||||
|
||||
/*return <Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>;
|
||||
*/
|
||||
|
||||
return {};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Finds Pets by tags
|
||||
* Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.
|
||||
*
|
||||
* tags List Tags to filter by
|
||||
* returns List
|
||||
**/
|
||||
async findPetsByTags(req, resp) {
|
||||
console.log("findPetsByTags");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
/*return {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
};
|
||||
*/
|
||||
|
||||
/*return <Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>;
|
||||
*/
|
||||
|
||||
return {};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Find pet by ID
|
||||
* Returns a single pet
|
||||
*
|
||||
* petId Long ID of pet to return
|
||||
* returns Pet
|
||||
**/
|
||||
async getPetById(req, resp) {
|
||||
console.log("getPetById");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
/*return {
|
||||
"photoUrls" : [ "photoUrls", "photoUrls" ],
|
||||
"name" : "doggie",
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"name" : "name",
|
||||
"id" : 6
|
||||
},
|
||||
"tags" : [ {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
}, {
|
||||
"name" : "name",
|
||||
"id" : 1
|
||||
} ],
|
||||
"status" : "available"
|
||||
};
|
||||
*/
|
||||
|
||||
/*return <Pet>
|
||||
<id>123456789</id>
|
||||
<name>doggie</name>
|
||||
<photoUrls>
|
||||
<photoUrls>aeiou</photoUrls>
|
||||
</photoUrls>
|
||||
<tags>
|
||||
</tags>
|
||||
<status>aeiou</status>
|
||||
</Pet>;
|
||||
*/
|
||||
|
||||
return {};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Update an existing pet
|
||||
*
|
||||
* body Pet Pet object that needs to be added to the store
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
async updatePet(req, resp) {
|
||||
console.log("updatePet");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates a pet in the store with form data
|
||||
*
|
||||
* petId Long ID of pet that needs to be updated
|
||||
* name String Updated name of the pet (optional)
|
||||
* status String Updated status of the pet (optional)
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
async updatePetWithForm(req, resp) {
|
||||
console.log("updatePetWithForm");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* uploads an image
|
||||
*
|
||||
* petId Long ID of pet to update
|
||||
* additionalMetadata String Additional data to pass to server (optional)
|
||||
* file File file to upload (optional)
|
||||
* returns ApiResponse
|
||||
**/
|
||||
async uploadFile(req, resp) {
|
||||
console.log("uploadFile");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
/*return {
|
||||
"code" : 0,
|
||||
"type" : "type",
|
||||
"message" : "message"
|
||||
};
|
||||
*/
|
||||
|
||||
return {};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete purchase order by ID
|
||||
* For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors
|
||||
*
|
||||
* orderId String ID of the order that needs to be deleted
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
async deleteOrder(req, resp) {
|
||||
console.log("deleteOrder");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns pet inventories by status
|
||||
* Returns a map of status codes to quantities
|
||||
*
|
||||
* returns Map
|
||||
**/
|
||||
async getInventory(req, resp) {
|
||||
console.log("getInventory");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return {};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Find purchase order by ID
|
||||
* For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions
|
||||
*
|
||||
* orderId Long ID of pet that needs to be fetched
|
||||
* returns Order
|
||||
**/
|
||||
async getOrderById(req, resp) {
|
||||
console.log("getOrderById");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
/*return {
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
};
|
||||
*/
|
||||
|
||||
/*return <Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>;
|
||||
*/
|
||||
|
||||
return {};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Place an order for a pet
|
||||
*
|
||||
* body Order order placed for purchasing the pet
|
||||
* returns Order
|
||||
**/
|
||||
async placeOrder(req, resp) {
|
||||
console.log("placeOrder");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
/*return {
|
||||
"petId" : 6,
|
||||
"quantity" : 1,
|
||||
"id" : 0,
|
||||
"shipDate" : "2000-01-23T04:56:07.000+00:00",
|
||||
"complete" : false,
|
||||
"status" : "placed"
|
||||
};
|
||||
*/
|
||||
|
||||
/*return <Order>
|
||||
<id>123456789</id>
|
||||
<petId>123456789</petId>
|
||||
<quantity>123</quantity>
|
||||
<shipDate>2000-01-23T04:56:07.000Z</shipDate>
|
||||
<status>aeiou</status>
|
||||
<complete>true</complete>
|
||||
</Order>;
|
||||
*/
|
||||
|
||||
return {};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Create user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* body User Created user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
async createUser(req, resp) {
|
||||
console.log("createUser");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* body List List of user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
async createUsersWithArrayInput(req, resp) {
|
||||
console.log("createUsersWithArrayInput");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates list of users with given input array
|
||||
*
|
||||
* body List List of user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
async createUsersWithListInput(req, resp) {
|
||||
console.log("createUsersWithListInput");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* username String The name that needs to be deleted
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
async deleteUser(req, resp) {
|
||||
console.log("deleteUser");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Get user by user name
|
||||
*
|
||||
* username String The name that needs to be fetched. Use user1 for testing.
|
||||
* returns User
|
||||
**/
|
||||
async getUserByName(req, resp) {
|
||||
console.log("getUserByName");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
/*return {
|
||||
"firstName" : "firstName",
|
||||
"lastName" : "lastName",
|
||||
"password" : "password",
|
||||
"userStatus" : 6,
|
||||
"phone" : "phone",
|
||||
"id" : 0,
|
||||
"email" : "email",
|
||||
"username" : "username"
|
||||
};
|
||||
*/
|
||||
|
||||
/*return <User>
|
||||
<id>123456789</id>
|
||||
<username>aeiou</username>
|
||||
<firstName>aeiou</firstName>
|
||||
<lastName>aeiou</lastName>
|
||||
<email>aeiou</email>
|
||||
<password>aeiou</password>
|
||||
<phone>aeiou</phone>
|
||||
<userStatus>123</userStatus>
|
||||
</User>;
|
||||
*/
|
||||
|
||||
return {};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs user into the system
|
||||
*
|
||||
* username String The user name for login
|
||||
* password String The password for login in clear text
|
||||
* returns String
|
||||
**/
|
||||
async loginUser(req, resp) {
|
||||
console.log("loginUser");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return {};
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Logs out current logged in user session
|
||||
*
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
async logoutUser(req, resp) {
|
||||
console.log("logoutUser");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Updated user
|
||||
* This can only be done by the logged in user.
|
||||
*
|
||||
* username String name that need to be deleted
|
||||
* body User Updated user object
|
||||
* no response value expected for this operation
|
||||
**/
|
||||
async updateUser(req, resp) {
|
||||
console.log("updateUser");
|
||||
|
||||
// TODO implement this endpoint
|
||||
|
||||
return;
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
module.exports = config => new Service();
|
||||
@@ -120,8 +120,7 @@ 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
|
||||
@@ -333,8 +332,7 @@ 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
|
||||
@@ -354,8 +352,7 @@ 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
|
||||
|
||||
@@ -131,8 +131,7 @@ 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
|
||||
@@ -368,8 +367,7 @@ 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
|
||||
@@ -392,8 +390,7 @@ 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
|
||||
@@ -1199,8 +1196,7 @@ 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:
|
||||
|
||||
@@ -93,8 +93,3 @@
|
||||
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.
|
Before Width: | Height: | Size: 29 KiB |
Reference in New Issue
Block a user