Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Autoset constants (Required fields having single valid enum value) C# Implementation of #16547 #17954

Merged
merged 2 commits into from
Mar 9, 2024

Conversation

prashant-pant
Copy link
Contributor

Code Changes

Partial implementation of #16547
If autosetConstants is set to True, the generated code by C# generator will hardcode values for any Header / Query Param which is marked as required and can only have a single valid enum value.
The single valued required enum i.e. The constant param will be removed from the method signature.

Testing

A test case has been added that asserts that if autosetConstants is set to true then the constant key/value pair is being set in the generated code.
I've run ./bin/generate-samples.sh and there is no change in existing code generation if the new autosetConstants property is not set, Therefore there should not be any risk in getting this change merged.

@wing328
Copy link
Member

wing328 commented Feb 28, 2024

thanks for the PR.

can you please also update the following API template files as well?

  • modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache
  • modules/openapi-generator/src/main/resources/csharp/libraries/httpclient/api.mustache

@wing328 wing328 added this to the 7.4.0 milestone Feb 28, 2024
@prashant-pant prashant-pant force-pushed the autoset-constants branch 2 times, most recently from 4c37865 to 4fbafb1 Compare February 29, 2024 10:30
@prashant-pant
Copy link
Contributor Author

prashant-pant commented Feb 29, 2024

thanks for the PR.

can you please also update the following API template files as well?

* modules/openapi-generator/src/main/resources/csharp/libraries/generichost/api.mustache

* modules/openapi-generator/src/main/resources/csharp/libraries/httpclient/api.mustache

Done in 4fbafb1
PTAL

@prashant-pant prashant-pant reopened this Feb 29, 2024
@wing328
Copy link
Member

wing328 commented Mar 1, 2024

cc
@mandrean (2017/08) @shibayan (2020/02) @Blackclaws (2021/03) @lucamazzanti (2021/05) @iBicha (2023/07)

@prashant-pant prashant-pant force-pushed the autoset-constants branch 2 times, most recently from 9468c6e to f7acb0b Compare March 1, 2024 05:30
@wing328 wing328 merged commit 31cff44 into OpenAPITools:master Mar 9, 2024
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants