Skip to content

Commit 4607b0e

Browse files
authored
Merge branch 'master' into ruby-multipart-content-type
2 parents 73a9382 + 83b41c4 commit 4607b0e

File tree

112 files changed

+761
-243
lines changed

Some content is hidden

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

112 files changed

+761
-243
lines changed

README.md

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
[![Java Test](https://img.shields.io/jenkins/build.svg?jobUrl=https://jenkins.swagger.io/job/oss-swagger-codegen-master)](https://jenkins.swagger.io/view/OSS%20-%20Java/job/oss-swagger-codegen-master)
1111
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/swagger-api/swagger-codegen?branch=master&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/swaggerhub-bot/swagger-codegen)
1212

13-
- 3.0.17-SNAPSHOT: [![Build Status](https://img.shields.io/travis/swagger-api/swagger-codegen/3.0.0.svg?label=Petstore%20Integration%20Test)](https://travis-ci.org/swagger-api/swagger-codegen)
13+
- 3.0.19-SNAPSHOT: [![Build Status](https://img.shields.io/travis/swagger-api/swagger-codegen/3.0.0.svg?label=Petstore%20Integration%20Test)](https://travis-ci.org/swagger-api/swagger-codegen)
1414
[![Java Test](https://img.shields.io/jenkins/build.svg?jobUrl=https://jenkins.swagger.io/job/oss-swagger-codegen-3)](https://jenkins.swagger.io/view/OSS%20-%20Java/job/oss-swagger-codegen-3)
1515
[![Windows Test](https://ci.appveyor.com/api/projects/status/github/swagger-api/swagger-codegen?branch=3.0.0&svg=true&passingText=Windows%20Test%20-%20OK&failingText=Windows%20Test%20-%20Fails)](https://ci.appveyor.com/project/swaggerhub-bot/swagger-codegen)
1616

@@ -70,7 +70,7 @@ dependency example:
7070
<dependency>
7171
<groupId>io.swagger.codegen.v3</groupId>
7272
<artifactId>swagger-codegen-maven-plugin</artifactId>
73-
<version>3.0.16</version>
73+
<version>3.0.18</version>
7474
</dependency>
7575
```
7676

@@ -134,8 +134,10 @@ The OpenAPI Specification has undergone 3 revisions since initial creation in 20
134134

135135
Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
136136
-------------------------- | ------------ | -------------------------- | -----
137-
3.0.17-SNAPSHOT (current 3.0.0, upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/codegen/v3/swagger-codegen-cli/3.0.17-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release
138-
[3.0.16](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.16) (**current stable**) | 2020-01-15 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.16](https://github.com/swagger-api/swagger-codegen/tree/v3.0.16)
137+
3.0.19-SNAPSHOT (current 3.0.0, upcoming minor release) [SNAPSHOT](https://oss.sonatype.org/content/repositories/snapshots/io/swagger/codegen/v3/swagger-codegen-cli/3.0.19-SNAPSHOT/)| TBD | 1.0, 1.1, 1.2, 2.0, 3.0 | Minor release
138+
[3.0.18](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.18) (**current stable**) | 2020-02-26 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.18](https://github.com/swagger-api/swagger-codegen/tree/v3.0.18)
139+
[3.0.17](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.17) (**current stable**) | 2020-02-23 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.17](https://github.com/swagger-api/swagger-codegen/tree/v3.0.17)
140+
[3.0.17](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.16) (**current stable**) | 2020-01-15 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.16](https://github.com/swagger-api/swagger-codegen/tree/v3.0.16)
139141
[3.0.15](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.15) (**current stable**) | 2020-01-03 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.15](https://github.com/swagger-api/swagger-codegen/tree/v3.0.15)
140142
[3.0.14](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.14) | 2019-11-16 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.14](https://github.com/swagger-api/swagger-codegen/tree/v3.0.14)
141143
[3.0.13](https://github.com/swagger-api/swagger-codegen/releases/tag/v3.0.13) | 2019-10-16 | 1.0, 1.1, 1.2, 2.0, 3.0 | [tag v3.0.13](https://github.com/swagger-api/swagger-codegen/tree/v3.0.13)
@@ -179,12 +181,16 @@ Swagger Codegen Version | Release Date | OpenAPI Spec compatibility | Notes
179181
If you're looking for the latest stable version, you can grab it directly from Maven.org (Java 8 runtime at a minimum):
180182

181183
```sh
182-
wget http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.12/swagger-codegen-cli-2.4.12.jar -O swagger-codegen-cli.jar
184+
# Download current stable 2.x.x branch (Swagger and OpenAPI version 2)
185+
wget https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.12/swagger-codegen-cli-2.4.12.jar -O swagger-codegen-cli.jar
186+
187+
# Download current stable 3.x.x branch (OpenAPI version 3)
188+
wget https://repo1.maven.org/maven2/io/swagger/codegen/v3/swagger-codegen-cli/3.0.18/swagger-codegen-cli-3.0.18.jar -O swagger-codegen-cli.jar
183189

184190
java -jar swagger-codegen-cli.jar help
185191
```
186192

187-
For Windows users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g. `Invoke-WebRequest -OutFile swagger-codegen-cli.jar http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.12/swagger-codegen-cli-2.4.12.jar`
193+
For Windows users, you will need to install [wget](http://gnuwin32.sourceforge.net/packages/wget.htm) or you can use Invoke-WebRequest in PowerShell (3.0+), e.g. `Invoke-WebRequest -OutFile swagger-codegen-cli.jar https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.12/swagger-codegen-cli-2.4.12.jar`
188194

189195
On a mac, it's even easier with `brew`:
190196
```sh
@@ -329,7 +335,7 @@ java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar generate \
329335
```
330336
(if you're on Windows, replace the last command with `java -jar modules\swagger-codegen-cli\target\swagger-codegen-cli.jar generate -i http://petstore.swagger.io/v2/swagger.json -l php -o c:\temp\php_api_client`)
331337

332-
You can also download the JAR (latest release) directly from [maven.org](http://central.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.12/swagger-codegen-cli-2.4.12.jar)
338+
You can also download the JAR (latest release) directly from [maven.org](https://repo1.maven.org/maven2/io/swagger/swagger-codegen-cli/2.4.12/swagger-codegen-cli-2.4.12.jar)
333339

334340
To get a list of **general** options available, please run `java -jar modules/swagger-codegen-cli/target/swagger-codegen-cli.jar help generate`
335341

@@ -760,7 +766,7 @@ For example, to generate Ruby API client, simply send the following HTTP request
760766
```sh
761767
curl -X POST -H "content-type:application/json" -d '{"swaggerUrl":"http://petstore.swagger.io/v2/swagger.json"}' https://generator.swagger.io/api/gen/clients/ruby
762768
```
763-
Then you will receieve a JSON response with the URL to download the zipped code.
769+
Then you will receive a JSON response with the URL to download the zipped code.
764770

765771
To customize the SDK, you can `POST` to `https://generator.swagger.io/gen/clients/{language}` with the following HTTP body:
766772
```json

modules/swagger-codegen-cli/src/main/java/io/swagger/codegen/cmd/Meta.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import java.io.File;
1717
import java.io.IOException;
1818
import java.io.Reader;
19+
import java.nio.charset.StandardCharsets;
1920
import java.util.List;
2021
import java.util.Map;
2122

@@ -115,7 +116,7 @@ public File convert(SupportingFile support) {
115116
LOGGER.info("copying file to {}", outputFile.getAbsolutePath());
116117
}
117118

118-
FileUtils.writeStringToFile(outputFile, formatted);
119+
FileUtils.writeStringToFile(outputFile, formatted, StandardCharsets.UTF_8);
119120
return outputFile;
120121

121122
} catch (IOException e) {

modules/swagger-codegen/src/main/java/io/swagger/codegen/MetaGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import java.io.File;
1515
import java.io.IOException;
1616
import java.io.Reader;
17+
import java.nio.charset.StandardCharsets;
1718
import java.util.ArrayList;
1819
import java.util.HashMap;
1920
import java.util.List;
@@ -166,7 +167,7 @@ public Reader getTemplate(String name) {
166167
files.add(new File(outputFilename));
167168
} else {
168169
String template = readTemplate(templateDir + File.separator + support.templateFile);
169-
FileUtils.writeStringToFile(new File(outputFilename), template);
170+
FileUtils.writeStringToFile(new File(outputFilename), template, StandardCharsets.UTF_8);
170171
LOGGER.info("copying file to " + outputFilename);
171172
files.add(new File(outputFilename));
172173
}

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/AspNetCoreServerCodegen.java

Lines changed: 23 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
2424

2525
private String packageGuid = "{" + randomUUID().toString().toUpperCase() + "}";
26-
private final String DEFAULT_ASP_NET_CORE_VERSION = "2.2";
26+
private final String DEFAULT_ASP_NET_CORE_VERSION = "3.0";
2727
private String aspNetCoreVersion;
2828

2929
@SuppressWarnings("hiding")
@@ -64,7 +64,7 @@ public AspNetCoreServerCodegen() {
6464
sourceFolder);
6565

6666
addOption(CodegenConstants.ASP_NET_CORE_VERSION,
67-
"aspnetcore version to use, current options are: 2.0, 2.1 and 2.2 (default)",
67+
"aspnetcore version to use, current options are: 2.0, 2.1, 2.2 and 3.0 (default)",
6868
this.aspNetCoreVersion);
6969

7070
addOption(CodegenConstants.INTERFACE_ONLY,
@@ -133,16 +133,35 @@ public void processOpts() {
133133
apiTemplateFiles.put("controller.mustache", ".cs");
134134
addInterfaceControllerTemplate(interfaceOnly, interfaceController);
135135

136+
supportingFiles.add(new SupportingFile("Filters" + File.separator + "BasePathFilter.mustache", packageFolder + File.separator + "Filters", "BasePathFilter.cs"));
137+
supportingFiles.add(new SupportingFile("Filters" + File.separator + "GeneratePathParamsValidationFilter.mustache", packageFolder + File.separator + "Filters", "GeneratePathParamsValidationFilter.cs"));
138+
139+
supportingFiles.add(new SupportingFile("Startup.mustache", packageFolder, "Startup.cs"));
136140
supportingFiles.add(new SupportingFile("Program.mustache", packageFolder, "Program.cs"));
137141
supportingFiles.add(new SupportingFile("Project.csproj.mustache", packageFolder, this.packageName + ".csproj"));
138142
supportingFiles.add(new SupportingFile("Dockerfile.mustache", packageFolder, "Dockerfile"));
139-
} else {
143+
} else if (this.aspNetCoreVersion.equals("2.1")) {
140144
apiTemplateFiles.put("2.1/controller.mustache", ".cs");
141145
addInterfaceControllerTemplate(interfaceOnly, interfaceController);
142146

147+
supportingFiles.add(new SupportingFile("Filters" + File.separator + "BasePathFilter.mustache", packageFolder + File.separator + "Filters", "BasePathFilter.cs"));
148+
supportingFiles.add(new SupportingFile("Filters" + File.separator + "GeneratePathParamsValidationFilter.mustache", packageFolder + File.separator + "Filters", "GeneratePathParamsValidationFilter.cs"));
149+
150+
supportingFiles.add(new SupportingFile("Startup.mustache", packageFolder, "Startup.cs"));
143151
supportingFiles.add(new SupportingFile("2.1/Program.mustache", packageFolder, "Program.cs"));
144152
supportingFiles.add(new SupportingFile("2.1/Project.csproj.mustache", packageFolder, this.packageName + ".csproj"));
145153
supportingFiles.add(new SupportingFile("2.1/Dockerfile.mustache", packageFolder, "Dockerfile"));
154+
} else {
155+
apiTemplateFiles.put("3.0/controller.mustache", ".cs");
156+
addInterfaceControllerTemplate(interfaceOnly, interfaceController);
157+
158+
supportingFiles.add(new SupportingFile("3.0" + File.separator + "Filters" + File.separator + "BasePathFilter.mustache", packageFolder + File.separator + "Filters", "BasePathFilter.cs"));
159+
supportingFiles.add(new SupportingFile("3.0" + File.separator + "Filters" + File.separator + "GeneratePathParamsValidationFilter.mustache", packageFolder + File.separator + "Filters", "GeneratePathParamsValidationFilter.cs"));
160+
161+
supportingFiles.add(new SupportingFile("3.0/Startup.mustache", packageFolder, "Startup.cs"));
162+
supportingFiles.add(new SupportingFile("3.0/Program.mustache", packageFolder, "Program.cs"));
163+
supportingFiles.add(new SupportingFile("3.0/Project.csproj.mustache", packageFolder, this.packageName + ".csproj"));
164+
supportingFiles.add(new SupportingFile("3.0/Dockerfile.mustache", packageFolder, "Dockerfile"));
146165
}
147166

148167
additionalProperties.put("aspNetCoreVersion", aspNetCoreVersion);
@@ -159,20 +178,14 @@ public void processOpts() {
159178
supportingFiles.add(new SupportingFile("build.bat.mustache", "", "build.bat"));
160179
supportingFiles.add(new SupportingFile("README.mustache", "", "README.md"));
161180
supportingFiles.add(new SupportingFile("Solution.mustache", "", this.packageName + ".sln"));
162-
supportingFiles.add(new SupportingFile("Dockerfile.mustache", packageFolder, "Dockerfile"));
163181
supportingFiles.add(new SupportingFile("gitignore", packageFolder, ".gitignore"));
164182
supportingFiles.add(new SupportingFile("appsettings.json", packageFolder, "appsettings.json"));
165183

166-
supportingFiles.add(new SupportingFile("Startup.mustache", packageFolder, "Startup.cs"));
167184
supportingFiles.add(new SupportingFile("validateModel.mustache", packageFolder + File.separator + "Attributes", "ValidateModelStateAttribute.cs"));
168185
supportingFiles.add(new SupportingFile("web.config", packageFolder, "web.config"));
169186

170187
supportingFiles.add(new SupportingFile("Properties" + File.separator + "launchSettings.json", packageFolder + File.separator + "Properties", "launchSettings.json"));
171188

172-
supportingFiles.add(new SupportingFile("Filters" + File.separator + "BasePathFilter.mustache", packageFolder + File.separator + "Filters", "BasePathFilter.cs"));
173-
supportingFiles.add(new SupportingFile("Filters" + File.separator + "GeneratePathParamsValidationFilter.mustache", packageFolder + File.separator + "Filters", "GeneratePathParamsValidationFilter.cs"));
174-
175-
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "README.md", packageFolder + File.separator + "wwwroot", "README.md"));
176189
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "index.html", packageFolder + File.separator + "wwwroot", "index.html"));
177190
supportingFiles.add(new SupportingFile("wwwroot" + File.separator + "web.config", packageFolder + File.separator + "wwwroot", "web.config"));
178191

@@ -301,7 +314,7 @@ private void setAspNetCoreVersion(String optionValue) {
301314
return;
302315
}
303316
this.aspNetCoreVersion = optionValue;
304-
if (!this.aspNetCoreVersion.equals("2.0") && !this.aspNetCoreVersion.equals("2.1") && !this.aspNetCoreVersion.equals("2.2")) {
317+
if (!this.aspNetCoreVersion.equals("2.0") && !this.aspNetCoreVersion.equals("2.1") && !this.aspNetCoreVersion.equals("2.2") && !this.aspNetCoreVersion.equals("3.0")) {
305318
LOGGER.error("version '" + this.aspNetCoreVersion + "' is not supported, switching to default version: '" + DEFAULT_ASP_NET_CORE_VERSION + "'");
306319
this.aspNetCoreVersion = DEFAULT_ASP_NET_CORE_VERSION;
307320
}

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/JavaJAXRSSpecServerCodegen.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import java.io.File;
44
import java.io.IOException;
5+
import java.nio.charset.StandardCharsets;
56
import java.util.ArrayList;
67
import java.util.LinkedHashMap;
78
import java.util.List;
@@ -166,7 +167,7 @@ public void preprocessSwagger(Swagger swagger) {
166167
//copy input swagger to output folder
167168
try {
168169
String swaggerJson = Json.pretty(swagger);
169-
FileUtils.writeStringToFile(new File(outputFolder + File.separator + "swagger.json"), swaggerJson);
170+
FileUtils.writeStringToFile(new File(outputFolder + File.separator + "swagger.json"), swaggerJson, StandardCharsets.UTF_8);
170171
} catch (IOException e) {
171172
throw new RuntimeException(e.getMessage(), e.getCause());
172173
}

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/ScalaGatlingCodegen.java

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import org.apache.commons.lang3.StringUtils;
99

1010
import java.io.IOException;
11+
import java.nio.charset.StandardCharsets;
1112
import java.util.*;
1213
import java.io.File;
1314

@@ -252,7 +253,11 @@ public void preprocessSwagger(Swagger swagger) {
252253
operation.setVendorExtension("x-gatling-body-feeder", operation.getOperationId() + "BodyFeeder");
253254
operation.setVendorExtension("x-gatling-body-feeder-params", StringUtils.join(sessionBodyVars, ","));
254255
try {
255-
FileUtils.writeStringToFile(new File(outputFolder + File.separator + dataFolder + File.separator + operation.getOperationId() + "-" + "bodyParams.csv"), StringUtils.join(bodyFeederParams, ","));
256+
FileUtils.writeStringToFile(
257+
new File(outputFolder + File.separator + dataFolder + File.separator + operation.getOperationId() + "-" + "bodyParams.csv"),
258+
StringUtils.join(bodyFeederParams, ","),
259+
StandardCharsets.UTF_8
260+
);
256261
} catch (IOException ioe) {
257262
LOGGER.error("Could not create feeder file for operationId" + operation.getOperationId(), ioe);
258263
}
@@ -296,7 +301,11 @@ private void prepareGatlingData(Operation operation, Set<Parameter> parameters,
296301
operation.setVendorExtension("x-gatling-" + parameterType.toLowerCase() + "-params", vendorList);
297302
operation.setVendorExtension("x-gatling-" + parameterType.toLowerCase() + "-feeder", operation.getOperationId() + parameterType.toUpperCase() + "Feeder");
298303
try {
299-
FileUtils.writeStringToFile(new File(outputFolder + File.separator + dataFolder + File.separator + operation.getOperationId() + "-" + parameterType.toLowerCase() + "Params.csv"), StringUtils.join(parameterNames, ","));
304+
FileUtils.writeStringToFile(
305+
new File(outputFolder + File.separator + dataFolder + File.separator + operation.getOperationId() + "-" + parameterType.toLowerCase() + "Params.csv"),
306+
StringUtils.join(parameterNames, ","),
307+
StandardCharsets.UTF_8
308+
);
300309
} catch (IOException ioe) {
301310
LOGGER.error("Could not create feeder file for operationId" + operation.getOperationId(), ioe);
302311
}

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwaggerGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.swagger.codegen.languages;
22

33
import java.io.File;
4+
import java.nio.charset.StandardCharsets;
45
import java.util.List;
56
import java.util.Map;
67

@@ -62,7 +63,7 @@ public void processSwagger(Swagger swagger) {
6263

6364
try {
6465
String outputFile = outputFolder + File.separator + this.outputFile;
65-
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
66+
FileUtils.writeStringToFile(new File(outputFile), swaggerString, StandardCharsets.UTF_8);
6667
LOGGER.debug("wrote file to " + outputFile);
6768
} catch (Exception e) {
6869
LOGGER.error(e.getMessage(), e);

modules/swagger-codegen/src/main/java/io/swagger/codegen/languages/SwaggerYamlGenerator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import org.slf4j.LoggerFactory;
2121

2222
import java.io.File;
23+
import java.nio.charset.StandardCharsets;
2324
import java.util.List;
2425
import java.util.Map;
2526

@@ -84,7 +85,7 @@ public void processSwagger(Swagger swagger) {
8485
configureMapper(mapper);
8586
String swaggerString = mapper.writeValueAsString(swagger);
8687
String outputFile = outputFolder + File.separator + this.outputFile;
87-
FileUtils.writeStringToFile(new File(outputFile), swaggerString);
88+
FileUtils.writeStringToFile(new File(outputFile), swaggerString, StandardCharsets.UTF_8);
8889
LOGGER.debug("wrote file to " + outputFile);
8990
} catch (Exception e) {
9091
LOGGER.error(e.getMessage(), e);
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
FROM mcr.microsoft.com/dotnet/core/sdk:{{aspNetCoreVersion}} AS build-env
2+
WORKDIR /app
3+
4+
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
5+
6+
# copy csproj and restore as distinct layers
7+
COPY *.csproj ./
8+
RUN dotnet restore
9+
10+
# copy everything else and build
11+
COPY . ./
12+
RUN dotnet publish -c Release -o out
13+
14+
# build runtime image
15+
FROM mcr.microsoft.com/dotnet/core/aspnet:{{aspNetCoreVersion}}
16+
WORKDIR /app
17+
COPY --from=build-env /app/out .
18+
ENTRYPOINT ["dotnet", "{{packageName}}.dll"]

0 commit comments

Comments
 (0)