Skip to content

Commit 5780530

Browse files
committed
updates sample for aspnet core
1 parent b418914 commit 5780530

File tree

149 files changed

+16282
-157
lines changed

Some content is hidden

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

149 files changed

+16282
-157
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/usr/bin/env bash
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -Dlogback.configurationFile=bin/logback.xml"
29+
ags="$@ generate -l aspnetcore -i modules/swagger-codegen/src/test/resources/3_0_0/petstore-mixed.yaml -o samples/server/petstore/aspnetcore-mixed --flatten-inline-schema true"
30+
31+
java $JAVA_OPTS -jar $executable $ags

modules/swagger-codegen/src/test/resources/3_0_0/petstore-mixed.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1475,6 +1475,15 @@ components:
14751475
example:
14761476
id: 0
14771477
category: "test-category-name"
1478+
UserWrapper:
1479+
type: object
1480+
properties:
1481+
users:
1482+
$ref: '#/components/schemas/Users'
1483+
Users:
1484+
type: array
1485+
items:
1486+
$ref: '#/components/schemas/User'
14781487
User:
14791488
type: object
14801489
properties:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
3.0.20-SNAPSHOT
1+
3.0.23-SNAPSHOT
Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,22 @@
1-
Microsoft Visual Studio Solution File, Format Version 12.00
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
23
# Visual Studio 15
3-
VisualStudioVersion = 15.0.26114.2
4+
VisualStudioVersion = 15.0.27428.2043
45
MinimumVisualStudioVersion = 10.0.40219.1
5-
Project("{8BB2217D-0F2D-49D1-97BC-3654ED321F3B}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{19CBD201-C545-44C5-B34D-1036EB6A3049}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "IO.Swagger", "src\IO.Swagger\IO.Swagger.csproj", "{00FFFCCA-8BCB-400B-AB0B-33130D4617AB}"
67
EndProject
78
Global
8-
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9-
Debug|Any CPU = Debug|Any CPU
10-
Release|Any CPU = Release|Any CPU
11-
EndGlobalSection
12-
GlobalSection(ProjectConfigurationPlatforms) = postSolution
13-
{19CBD201-C545-44C5-B34D-1036EB6A3049}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
14-
{19CBD201-C545-44C5-B34D-1036EB6A3049}.Debug|Any CPU.Build.0 = Debug|Any CPU
15-
{19CBD201-C545-44C5-B34D-1036EB6A3049}.Release|Any CPU.ActiveCfg = Release|Any CPU
16-
{19CBD201-C545-44C5-B34D-1036EB6A3049}.Release|Any CPU.Build.0 = Release|Any CPU
17-
EndGlobalSection
18-
GlobalSection(SolutionProperties) = preSolution
19-
HideSolutionNode = FALSE
20-
EndGlobalSection
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{00FFFCCA-8BCB-400B-AB0B-33130D4617AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{00FFFCCA-8BCB-400B-AB0B-33130D4617AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{00FFFCCA-8BCB-400B-AB0B-33130D4617AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{00FFFCCA-8BCB-400B-AB0B-33130D4617AB}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
2122
EndGlobal

samples/server/petstore/aspnetcore-interface-controller/src/IO.Swagger/Controllers/DefaultApi.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,17 @@ public class DefaultApiController : ControllerBase, IDefaultApiController
3636
[Authorize(AuthenticationSchemes = BearerAuthenticationHandler.SchemeName)]
3737
[ValidateModelState]
3838
[SwaggerOperation("TestMethod")]
39-
[SwaggerResponse(statusCode: 200, type: typeof(List<Test>), description: "peticion realizada con exito")]
39+
[SwaggerResponse(statusCode: 200, type: typeof(List<string>), description: "peticion realizada con exito")]
4040
public virtual IActionResult TestMethod()
4141
{
4242
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
43-
// return StatusCode(200, default(List<Test>));
43+
// return StatusCode(200, default(List<string>));
4444
string exampleJson = null;
4545
exampleJson = "[ \"\", \"\" ]";
4646

4747
var example = exampleJson != null
48-
? JsonConvert.DeserializeObject<List<Test>>(exampleJson)
49-
: default(List<Test>); //TODO: Change the data returned
48+
? JsonConvert.DeserializeObject<List<string>>(exampleJson)
49+
: default(List<string>); //TODO: Change the data returned
5050
return new ObjectResult(example);
5151
}
5252
}

samples/server/petstore/aspnetcore-interface-controller/src/IO.Swagger/Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM mcr.microsoft.com/dotnet/core/sdk:3.0 AS build-env
1+
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS build-env
22
WORKDIR /app
33

44
ENV DOTNET_CLI_TELEMETRY_OPTOUT 1
@@ -12,7 +12,7 @@ COPY . ./
1212
RUN dotnet publish -c Release -o out
1313

1414
# build runtime image
15-
FROM mcr.microsoft.com/dotnet/core/aspnet:3.0
15+
FROM mcr.microsoft.com/dotnet/core/aspnet:3.1
1616
WORKDIR /app
1717
COPY --from=build-env /app/out .
1818

samples/server/petstore/aspnetcore-interface-controller/src/IO.Swagger/IO.Swagger.csproj

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22
<PropertyGroup>
33
<Description>IO.Swagger</Description>
44
<Copyright>IO.Swagger</Copyright>
5-
<TargetFramework>netcoreapp3.0</TargetFramework>
5+
<TargetFramework>netcoreapp3.1</TargetFramework>
66
<GenerateDocumentationFile>true</GenerateDocumentationFile>
77
<PreserveCompilationContext>true</PreserveCompilationContext>
88
<AssemblyName>IO.Swagger</AssemblyName>
99
<PackageId>IO.Swagger</PackageId>
1010
</PropertyGroup>
1111
<ItemGroup>
12-
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.0.0-rc4"/>
13-
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.0.0-rc4"/>
14-
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.0.0-rc4"/>
15-
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.0.0-rc4" />
12+
<PackageReference Include="Swashbuckle.AspNetCore" Version="5.5.1"/>
13+
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerGen" Version="5.5.1"/>
14+
<PackageReference Include="Swashbuckle.AspNetCore.SwaggerUI" Version="5.5.1"/>
15+
<PackageReference Include="Swashbuckle.AspNetCore.Annotations" Version="5.5.1" />
16+
<PackageReference Include="Swashbuckle.AspNetCore.Newtonsoft" Version="5.5.1"/>
1617
</ItemGroup>
1718
<ItemGroup>
1819
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="2.0.4" />

samples/server/petstore/aspnetcore-interface-controller/src/IO.Swagger/Properties/launchSettings.json

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,18 @@
1919
"web": {
2020
"commandName": "Project",
2121
"launchBrowser": true,
22-
"launchUrl": "http://localhost:5000/swagger/",
22+
"launchUrl": "swagger",
23+
"applicationUrl": "https://localhost:5001;http://localhost:5000",
2324
"environmentVariables": {
2425
"ASPNETCORE_ENVIRONMENT": "Development"
2526
}
27+
},
28+
"Docker": {
29+
"commandName": "Docker",
30+
"launchBrowser": true,
31+
"launchUrl": "{Scheme}://{ServiceHost}:{ServicePort}/swagger",
32+
"publishAllPorts": true,
33+
"useSSL": true
2634
}
2735
}
2836
}

samples/server/petstore/aspnetcore-interface-controller/src/IO.Swagger/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public void ConfigureServices(IServiceCollection services)
8080
{
8181
Version = "1.0.0",
8282
Title = "Swagger Petstore",
83-
Description = "Swagger Petstore (ASP.NET Core 3.0)",
83+
Description = "Swagger Petstore (ASP.NET Core 3.1)",
8484
Contact = new OpenApiContact()
8585
{
8686
Name = "Swagger Codegen Contributors",

samples/server/petstore/aspnetcore-interface-controller/src/IO.Swagger/wwwroot/swagger-original.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1080,7 +1080,8 @@
10801080
}
10811081
},
10821082
"Test" : {
1083-
"type" : "string"
1083+
"type" : "string",
1084+
"example" : ""
10841085
},
10851086
"NullableEnumModel" : {
10861087
"type" : "object",

0 commit comments

Comments
 (0)