Skip to content

Commit 8314d41

Browse files
More samples changes
1 parent 2d45cca commit 8314d41

16 files changed

Lines changed: 606 additions & 59 deletions

File tree

bin/configs/aspnetcore-8.0-abstract-class.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,7 @@ outputDir: samples/server/petstore/aspnetcore-8.0-abstract-class
33
inputSpec: modules/openapi-generator/src/test/resources/3_0/aspnetcore/petstore.yaml
44
templateDir: modules/openapi-generator/src/main/resources/aspnetcore/3.0
55
additionalProperties:
6+
packageGuid: '{3C799344-F285-4669-8FD5-7ED9B795D5C5}'
67
aspnetCoreVersion: "8.0"
8+
userSecretsGuid: 'cb87e868-8646-48ef-9bb6-344b537d0d37'
79
classModifier: abstract

samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/DefaultApi.cs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,13 @@ public abstract class DefaultApiController : ControllerBase
3333
[HttpGet]
3434
[Route("/v2/test")]
3535
[ValidateModelState]
36-
public abstract IActionResult TestGet([FromQuery (Name = "testQuery")]TestEnum? testQuery);
36+
public virtual IActionResult TestGet([FromQuery (Name = "testQuery")]TestEnum? testQuery)
37+
{
38+
39+
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
40+
// return StatusCode(200);
41+
42+
throw new NotImplementedException();
43+
}
3744
}
3845
}

samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/FakeApi.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,20 @@ public abstract class FakeApiController : ControllerBase
3333
[Route("/v2/fake/nullable_example_test")]
3434
[ValidateModelState]
3535
[ProducesResponseType(statusCode: 200, type: typeof(TestNullable))]
36-
public abstract IActionResult FakeNullableExampleTest();
36+
public virtual IActionResult FakeNullableExampleTest()
37+
{
38+
39+
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
40+
// return StatusCode(200, default);
41+
string exampleJson = null;
42+
exampleJson = "{\r\n \"nullableName\" : \"nullableName\",\r\n \"name\" : \"name\"\r\n}";
43+
44+
var example = exampleJson != null
45+
? JsonConvert.DeserializeObject<TestNullable>(exampleJson)
46+
: default;
47+
//TODO: Change the data returned
48+
return new ObjectResult(example);
49+
}
3750

3851
/// <summary>
3952
/// fake endpoint to test parameter example (object)
@@ -43,6 +56,13 @@ public abstract class FakeApiController : ControllerBase
4356
[HttpGet]
4457
[Route("/v2/fake/parameter_example_test")]
4558
[ValidateModelState]
46-
public abstract IActionResult FakeParameterExampleTest([FromQuery (Name = "data")][Required()]Pet data);
59+
public virtual IActionResult FakeParameterExampleTest([FromQuery (Name = "data")][Required()]Pet data)
60+
{
61+
62+
//TODO: Uncomment the next line to return response 0 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
63+
// return StatusCode(0);
64+
65+
throw new NotImplementedException();
66+
}
4767
}
4868
}

samples/server/petstore/aspnetcore-6.0-useSwashBuckle/src/Org.OpenAPITools/Controllers/PetApi.cs

Lines changed: 121 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,23 @@ public abstract class PetApiController : ControllerBase
3636
[Consumes("application/json", "application/xml")]
3737
[ValidateModelState]
3838
[ProducesResponseType(statusCode: 200, type: typeof(Pet))]
39-
public abstract IActionResult AddPet([FromBody]Pet pet);
39+
public virtual IActionResult AddPet([FromBody]Pet pet)
40+
{
41+
42+
//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);
44+
//TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
45+
// return StatusCode(405);
46+
string exampleJson = null;
47+
exampleJson = "{\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n}";
48+
exampleJson = "<Pet>\n <id>123456789</id>\n <Category>\n <id>123456789</id>\n <name>aeiou</name>\n </Category>\n <name>doggie</name>\n <photoUrls>\n <photoUrls>aeiou</photoUrls>\n </photoUrls>\n <tags>\n <Tag>\n <id>123456789</id>\n <name>aeiou</name>\n </Tag>\n </tags>\n <status>aeiou</status>\n</Pet>";
49+
50+
var example = exampleJson != null
51+
? JsonConvert.DeserializeObject<Pet>(exampleJson)
52+
: default;
53+
//TODO: Change the data returned
54+
return new ObjectResult(example);
55+
}
4056

4157
/// <summary>
4258
/// Deletes a pet
@@ -47,7 +63,14 @@ public abstract class PetApiController : ControllerBase
4763
[HttpDelete]
4864
[Route("/v2/pet/{petId}")]
4965
[ValidateModelState]
50-
public abstract IActionResult DeletePet([FromRoute (Name = "petId")][Required]long petId, [FromHeader (Name = "api_key")]string apiKey);
66+
public virtual IActionResult DeletePet([FromRoute (Name = "petId")][Required]long petId, [FromHeader (Name = "api_key")]string apiKey)
67+
{
68+
69+
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
70+
// return StatusCode(400);
71+
72+
throw new NotImplementedException();
73+
}
5174

5275
/// <summary>
5376
/// Finds Pets by status
@@ -60,7 +83,23 @@ public abstract class PetApiController : ControllerBase
6083
[Route("/v2/pet/findByStatus")]
6184
[ValidateModelState]
6285
[ProducesResponseType(statusCode: 200, type: typeof(List<Pet>))]
63-
public abstract IActionResult FindPetsByStatus([FromQuery (Name = "status")][Required()]List<string> status);
86+
public virtual IActionResult FindPetsByStatus([FromQuery (Name = "status")][Required()]List<string> status)
87+
{
88+
89+
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
90+
// return StatusCode(200, default);
91+
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
92+
// return StatusCode(400);
93+
string exampleJson = null;
94+
exampleJson = "[ {\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n}, {\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n} ]";
95+
exampleJson = "<Pet>\n <id>123456789</id>\n <Category>\n <id>123456789</id>\n <name>aeiou</name>\n </Category>\n <name>doggie</name>\n <photoUrls>\n <photoUrls>aeiou</photoUrls>\n </photoUrls>\n <tags>\n <Tag>\n <id>123456789</id>\n <name>aeiou</name>\n </Tag>\n </tags>\n <status>aeiou</status>\n</Pet>";
96+
97+
var example = exampleJson != null
98+
? JsonConvert.DeserializeObject<List<Pet>>(exampleJson)
99+
: default;
100+
//TODO: Change the data returned
101+
return new ObjectResult(example);
102+
}
64103

65104
/// <summary>
66105
/// Finds Pets by tags
@@ -74,7 +113,23 @@ public abstract class PetApiController : ControllerBase
74113
[ValidateModelState]
75114
[ProducesResponseType(statusCode: 200, type: typeof(List<Pet>))]
76115
[Obsolete]
77-
public abstract IActionResult FindPetsByTags([FromQuery (Name = "tags")][Required()]List<string> tags);
116+
public virtual IActionResult FindPetsByTags([FromQuery (Name = "tags")][Required()]List<string> tags)
117+
{
118+
119+
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
120+
// return StatusCode(200, default);
121+
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
122+
// return StatusCode(400);
123+
string exampleJson = null;
124+
exampleJson = "[ {\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n}, {\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n} ]";
125+
exampleJson = "<Pet>\n <id>123456789</id>\n <Category>\n <id>123456789</id>\n <name>aeiou</name>\n </Category>\n <name>doggie</name>\n <photoUrls>\n <photoUrls>aeiou</photoUrls>\n </photoUrls>\n <tags>\n <Tag>\n <id>123456789</id>\n <name>aeiou</name>\n </Tag>\n </tags>\n <status>aeiou</status>\n</Pet>";
126+
127+
var example = exampleJson != null
128+
? JsonConvert.DeserializeObject<List<Pet>>(exampleJson)
129+
: default;
130+
//TODO: Change the data returned
131+
return new ObjectResult(example);
132+
}
78133

79134
/// <summary>
80135
/// Find pet by ID
@@ -89,7 +144,25 @@ public abstract class PetApiController : ControllerBase
89144
[Authorize(Policy = "api_key")]
90145
[ValidateModelState]
91146
[ProducesResponseType(statusCode: 200, type: typeof(Pet))]
92-
public abstract IActionResult GetPetById([FromRoute (Name = "petId")][Required]long petId);
147+
public virtual IActionResult GetPetById([FromRoute (Name = "petId")][Required]long petId)
148+
{
149+
150+
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
151+
// return StatusCode(200, default);
152+
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
153+
// return StatusCode(400);
154+
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
155+
// return StatusCode(404);
156+
string exampleJson = null;
157+
exampleJson = "{\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n}";
158+
exampleJson = "<Pet>\n <id>123456789</id>\n <Category>\n <id>123456789</id>\n <name>aeiou</name>\n </Category>\n <name>doggie</name>\n <photoUrls>\n <photoUrls>aeiou</photoUrls>\n </photoUrls>\n <tags>\n <Tag>\n <id>123456789</id>\n <name>aeiou</name>\n </Tag>\n </tags>\n <status>aeiou</status>\n</Pet>";
159+
160+
var example = exampleJson != null
161+
? JsonConvert.DeserializeObject<Pet>(exampleJson)
162+
: default;
163+
//TODO: Change the data returned
164+
return new ObjectResult(example);
165+
}
93166

94167
/// <summary>
95168
/// Update an existing pet
@@ -104,7 +177,27 @@ public abstract class PetApiController : ControllerBase
104177
[Consumes("application/json", "application/xml")]
105178
[ValidateModelState]
106179
[ProducesResponseType(statusCode: 200, type: typeof(Pet))]
107-
public abstract IActionResult UpdatePet([FromBody]Pet pet);
180+
public virtual IActionResult UpdatePet([FromBody]Pet pet)
181+
{
182+
183+
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
184+
// return StatusCode(200, default);
185+
//TODO: Uncomment the next line to return response 400 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
186+
// return StatusCode(400);
187+
//TODO: Uncomment the next line to return response 404 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
188+
// return StatusCode(404);
189+
//TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
190+
// return StatusCode(405);
191+
string exampleJson = null;
192+
exampleJson = "{\r\n \"photoUrls\" : [ \"photoUrls\", \"photoUrls\" ],\r\n \"name\" : \"doggie\",\r\n \"id\" : 0,\r\n \"category\" : {\r\n \"name\" : \"name\",\r\n \"id\" : 6\r\n },\r\n \"tags\" : [ {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n }, {\r\n \"name\" : \"name\",\r\n \"id\" : 1\r\n } ],\r\n \"status\" : \"available\"\r\n}";
193+
exampleJson = "<Pet>\n <id>123456789</id>\n <name>doggie</name>\n <photoUrls>\n <photoUrls>aeiou</photoUrls>\n </photoUrls>\n <tags>\n </tags>\n <status>aeiou</status>\n</Pet>";
194+
195+
var example = exampleJson != null
196+
? JsonConvert.DeserializeObject<Pet>(exampleJson)
197+
: default;
198+
//TODO: Change the data returned
199+
return new ObjectResult(example);
200+
}
108201

109202
/// <summary>
110203
/// Updates a pet in the store with form data
@@ -117,7 +210,14 @@ public abstract class PetApiController : ControllerBase
117210
[Route("/v2/pet/{petId}")]
118211
[Consumes("application/x-www-form-urlencoded")]
119212
[ValidateModelState]
120-
public abstract IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status);
213+
public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status)
214+
{
215+
216+
//TODO: Uncomment the next line to return response 405 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
217+
// return StatusCode(405);
218+
219+
throw new NotImplementedException();
220+
}
121221

122222
/// <summary>
123223
/// uploads an image
@@ -131,6 +231,19 @@ public abstract class PetApiController : ControllerBase
131231
[Consumes("multipart/form-data")]
132232
[ValidateModelState]
133233
[ProducesResponseType(statusCode: 200, type: typeof(ApiResponse))]
134-
public abstract IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, IFormFile file);
234+
public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, IFormFile file)
235+
{
236+
237+
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
238+
// return StatusCode(200, default);
239+
string exampleJson = null;
240+
exampleJson = "{\r\n \"code\" : 0,\r\n \"type\" : \"type\",\r\n \"message\" : \"message\"\r\n}";
241+
242+
var example = exampleJson != null
243+
? JsonConvert.DeserializeObject<ApiResponse>(exampleJson)
244+
: default;
245+
//TODO: Change the data returned
246+
return new ObjectResult(example);
247+
}
135248
}
136249
}

0 commit comments

Comments
 (0)