OpenAPITools / OpenAPITools/openapi-generator
[REQ] Respect `default` parameters in aspnetcore generator
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
Default parameters are not added to the generated controller methods by the aspnetcore generator
actual signature output:
public virtual IActionResult AGet([FromQuery (Name = "b")]bool? b)
expected:
public virtual IActionResult AGet([FromQuery (Name = "b")]bool b = false)
openapi-generator version
docker image b28b21d6f3da
OpenAPI declaration file content or url
openapi: 3.0.3
info:
title: example
version: 0.0.1
paths:
/a:
get:
parameters:
- name: b
in: query
schema:
type: boolean
default: false
responses:
'200':
description: OK
Generation Details
Docker & git-bash for Windows
Steps to reproduce
- add the above to the file
example.ymlin an otherwise empty folder - run the following bash command from that folder:
rm -rf out && MSYS_NO_PATHCONV=1 docker run --rm -v "${PWD}:/local" \
openapitools/openapi-generator-cli generate \
--input-spec "/local/example.yml" \
--output "/local/out/aspnetcore" \
--generator-name aspnetcore
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 the example.yml reproduction and run the documented Docker command using the aspnetcore generator. Inspect the generated controller method signature; done means the query parameter's declared default is preserved as a non-nullable bool with = false rather than becoming nullable.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, docker
- Domain
- backend, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100