swagger-api / swagger-api/swagger-codegen
[Csharp] - ParameterDescriptor is nullable.
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
I created my "OpenAPI.yaml" and I got ASPNetCore codes using OpenAPI Generator.
So, I started the Server and I access "http://localhost:xxxx/swagger/index.html" on the browser.
But I got Error.
I noticed that "par.ParameterDescriptor" is nullable.
(GeneratePathParamsValidationFilter.cs)
23: foreach (var par in pars)
24: {
25: var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes; // here!
would you please check this?
Swagger-codegen version
3.0.2
Command line used for generation
I'm using Windows Power Schell.
docker run --rm -v ${PWD}:/work --workdir=/work openapitools/openapi-generator-cli generate -i ./root.yml -g aspnetcore -o ./out/ASPNetCore -c ./config.yml
Steps to reproduce
- Create OpenAPI YAML file.
- Generate ASPNetCore code using openapi-generator-cli.
- Run the Server (using VisualStudio 2019) - debug mode.
- Access the Server on the Browser.
-> Get Error on Visual Studio.
Suggest a fix/enhancement
I tried it, and it works fine.
// var attributes = ((ControllerParameterDescriptor)par.ParameterDescriptor).ParameterInfo.CustomAttributes; // Original is comment out.
var cpd = (ControllerParameterDescriptor)par.ParameterDescriptor;
var attributes = cpd == null ? null : cpd.ParameterInfo.CustomAttributes;
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with GeneratePathParamsValidationFilter.cs in the generated ASPNetCore server and reproduce the failure using the provided Docker command and OpenAPI YAML. Trace why par.ParameterDescriptor is nullable and verify the generated server starts and serves its Swagger page without the error.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, docker, openapi
- Domain
- api, backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100