forked from loafle/openapi-generator-original
[csharp][aspnetcore] Enable Consumes Tag for Specs where not every operation consumes (#9039)
* Change break to consumes so that all operations will be processed * Update Samples
This commit is contained in:
parent
7e0382b08d
commit
b69fb79573
@ -453,10 +453,10 @@ public class AspNetCoreServerCodegen extends AbstractCSharpCodegen {
|
|||||||
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
List<CodegenOperation> ops = (List<CodegenOperation>) operations.get("operation");
|
||||||
for (CodegenOperation operation : ops) {
|
for (CodegenOperation operation : ops) {
|
||||||
if (operation.consumes == null) {
|
if (operation.consumes == null) {
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
if (operation.consumes.size() == 0) {
|
if (operation.consumes.size() == 0) {
|
||||||
break;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a consumes string for the operation we cannot iterate in the template as we need a ','
|
// Build a consumes string for the operation we cannot iterate in the template as we need a ','
|
||||||
|
@ -169,6 +169,7 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="405">Validation exception</response>
|
/// <response code="405">Validation exception</response>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[Route("/v2/pet")]
|
[Route("/v2/pet")]
|
||||||
|
[Consumes("application/json", "application/xml")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UpdatePet")]
|
[SwaggerOperation("UpdatePet")]
|
||||||
public virtual IActionResult UpdatePet([FromBody]Pet body)
|
public virtual IActionResult UpdatePet([FromBody]Pet body)
|
||||||
@ -193,6 +194,7 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="405">Invalid input</response>
|
/// <response code="405">Invalid input</response>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/v2/pet/{petId}")]
|
[Route("/v2/pet/{petId}")]
|
||||||
|
[Consumes("application/x-www-form-urlencoded")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UpdatePetWithForm")]
|
[SwaggerOperation("UpdatePetWithForm")]
|
||||||
public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status)
|
public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status)
|
||||||
@ -213,10 +215,11 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="200">successful operation</response>
|
/// <response code="200">successful operation</response>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/v2/pet/{petId}/uploadImage")]
|
[Route("/v2/pet/{petId}/uploadImage")]
|
||||||
|
[Consumes("multipart/form-data")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UploadFile")]
|
[SwaggerOperation("UploadFile")]
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")]
|
[SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")]
|
||||||
public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, System.IO.Stream file)
|
public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, IFormFile file)
|
||||||
{
|
{
|
||||||
|
|
||||||
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
@ -169,6 +169,7 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="405">Validation exception</response>
|
/// <response code="405">Validation exception</response>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[Route("/v2/pet")]
|
[Route("/v2/pet")]
|
||||||
|
[Consumes("application/json", "application/xml")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UpdatePet")]
|
[SwaggerOperation("UpdatePet")]
|
||||||
public virtual IActionResult UpdatePet([FromBody]Pet body)
|
public virtual IActionResult UpdatePet([FromBody]Pet body)
|
||||||
@ -193,6 +194,7 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="405">Invalid input</response>
|
/// <response code="405">Invalid input</response>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/v2/pet/{petId}")]
|
[Route("/v2/pet/{petId}")]
|
||||||
|
[Consumes("application/x-www-form-urlencoded")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UpdatePetWithForm")]
|
[SwaggerOperation("UpdatePetWithForm")]
|
||||||
public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status)
|
public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status)
|
||||||
@ -213,10 +215,11 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="200">successful operation</response>
|
/// <response code="200">successful operation</response>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/v2/pet/{petId}/uploadImage")]
|
[Route("/v2/pet/{petId}/uploadImage")]
|
||||||
|
[Consumes("multipart/form-data")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UploadFile")]
|
[SwaggerOperation("UploadFile")]
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")]
|
[SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")]
|
||||||
public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, System.IO.Stream file)
|
public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, IFormFile file)
|
||||||
{
|
{
|
||||||
|
|
||||||
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
@ -181,6 +181,7 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="405">Validation exception</response>
|
/// <response code="405">Validation exception</response>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[Route("/v2/pet")]
|
[Route("/v2/pet")]
|
||||||
|
[Consumes("application/json", "application/xml")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UpdatePet")]
|
[SwaggerOperation("UpdatePet")]
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")]
|
[SwaggerResponse(statusCode: 200, type: typeof(Pet), description: "successful operation")]
|
||||||
@ -215,6 +216,7 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="405">Invalid input</response>
|
/// <response code="405">Invalid input</response>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/v2/pet/{petId}")]
|
[Route("/v2/pet/{petId}")]
|
||||||
|
[Consumes("application/x-www-form-urlencoded")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UpdatePetWithForm")]
|
[SwaggerOperation("UpdatePetWithForm")]
|
||||||
public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status)
|
public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status)
|
||||||
@ -235,10 +237,11 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="200">successful operation</response>
|
/// <response code="200">successful operation</response>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/v2/pet/{petId}/uploadImage")]
|
[Route("/v2/pet/{petId}/uploadImage")]
|
||||||
|
[Consumes("multipart/form-data")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UploadFile")]
|
[SwaggerOperation("UploadFile")]
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")]
|
[SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")]
|
||||||
public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, System.IO.Stream file)
|
public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, IFormFile file)
|
||||||
{
|
{
|
||||||
|
|
||||||
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
@ -116,6 +116,7 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="400">Invalid Order</response>
|
/// <response code="400">Invalid Order</response>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/v2/store/order")]
|
[Route("/v2/store/order")]
|
||||||
|
[Consumes("application/json")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("PlaceOrder")]
|
[SwaggerOperation("PlaceOrder")]
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")]
|
[SwaggerResponse(statusCode: 200, type: typeof(Order), description: "successful operation")]
|
||||||
|
@ -201,6 +201,7 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
[HttpPut]
|
[HttpPut]
|
||||||
[Route("/v2/user/{username}")]
|
[Route("/v2/user/{username}")]
|
||||||
[Authorize(Policy = "api_key")]
|
[Authorize(Policy = "api_key")]
|
||||||
|
[Consumes("application/json")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UpdateUser")]
|
[SwaggerOperation("UpdateUser")]
|
||||||
public virtual IActionResult UpdateUser([FromRoute (Name = "username")][Required]string username, [FromBody]User user)
|
public virtual IActionResult UpdateUser([FromRoute (Name = "username")][Required]string username, [FromBody]User user)
|
||||||
|
@ -169,6 +169,7 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="405">Validation exception</response>
|
/// <response code="405">Validation exception</response>
|
||||||
[HttpPut]
|
[HttpPut]
|
||||||
[Route("/v2/pet")]
|
[Route("/v2/pet")]
|
||||||
|
[Consumes("application/json", "application/xml")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UpdatePet")]
|
[SwaggerOperation("UpdatePet")]
|
||||||
public virtual IActionResult UpdatePet([FromBody]Pet body)
|
public virtual IActionResult UpdatePet([FromBody]Pet body)
|
||||||
@ -193,6 +194,7 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="405">Invalid input</response>
|
/// <response code="405">Invalid input</response>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/v2/pet/{petId}")]
|
[Route("/v2/pet/{petId}")]
|
||||||
|
[Consumes("application/x-www-form-urlencoded")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UpdatePetWithForm")]
|
[SwaggerOperation("UpdatePetWithForm")]
|
||||||
public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status)
|
public virtual IActionResult UpdatePetWithForm([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "name")]string name, [FromForm (Name = "status")]string status)
|
||||||
@ -213,10 +215,11 @@ namespace Org.OpenAPITools.Controllers
|
|||||||
/// <response code="200">successful operation</response>
|
/// <response code="200">successful operation</response>
|
||||||
[HttpPost]
|
[HttpPost]
|
||||||
[Route("/v2/pet/{petId}/uploadImage")]
|
[Route("/v2/pet/{petId}/uploadImage")]
|
||||||
|
[Consumes("multipart/form-data")]
|
||||||
[ValidateModelState]
|
[ValidateModelState]
|
||||||
[SwaggerOperation("UploadFile")]
|
[SwaggerOperation("UploadFile")]
|
||||||
[SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")]
|
[SwaggerResponse(statusCode: 200, type: typeof(ApiResponse), description: "successful operation")]
|
||||||
public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, System.IO.Stream file)
|
public virtual IActionResult UploadFile([FromRoute (Name = "petId")][Required]long petId, [FromForm (Name = "additionalMetadata")]string additionalMetadata, IFormFile file)
|
||||||
{
|
{
|
||||||
|
|
||||||
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
//TODO: Uncomment the next line to return response 200 or use other options such as return this.NotFound(), return this.BadRequest(..), ...
|
||||||
|
Loading…
x
Reference in New Issue
Block a user