swagger-api / swagger-api/swagger-codegen

[aspnetcore ] problem with upload file and aspnetcore generation

Open
#9,331 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Mustache
Stars
17.8k
Forks
6k
PR merge metrics
No merged PRs in 30d

Description

Description

To define the upload of a file in OpenApi3.0, it's recommanded to use the following syntax in the body:
"schema":{
"type": "string",
"format": "binary"
}
The generator then generates a method with the folowing signature:

    [HttpPost]
    [Route("/myPath")]
    [ValidateModelState]
    [SwaggerOperation("FooPost")]
    [SwaggerResponse(statusCode: 201, type: typeof(fileId), description: "foo called")]
    public IActionResult foo([FromBody]System.Io.Stream body) { ...}

The generated code is used in VS 2017, aspnetcore 2.1
The problem is i never enter in this method and get "415 Unsupported Media Type" in the client (Postman).

Does anyone has an idea of what could be the problem ?

Swagger-codegen version : 3.3.4

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the generated ASP.NET Core method shown in the issue and the OpenAPI 3.0 file-upload schema, then reproduce the request in Postman using the stated Swagger Codegen 3.3.4 and ASP.NET Core 2.1 versions. Done means identifying why the generated action returns 415 and documenting or correcting generation so the upload request is accepted.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, openapi
Domain
api, backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.