OpenAPITools / OpenAPITools/openapi-generator
Mandatory parameters are assigned default values when generating Unity SDK using OpenAPI-Generator
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Hello,
I am using openapi-generator to create an SDK for Unity. Here is my generation script:
openapi-generator-cli generate -i swagger.json -g csharp-netcore --library unityWebRequest -o sdk-unity/ --skip-validate-spec --global-property modelTests=false --global-property apiTests=false --global-property modelDocs=false --global-property apiDocs=false --additional-properties packageName=BX.Rest
I have noticed that all methods in the resulting SDK have default values for their parameters, even for those that are marked as required in the swagger.json. Here's an example:
/// <param name="tutorialName">tutorialName (required).</param>
public CreateTutorialRaceBody(string tutorialName = default(string))
This seems strange because mandatory parameters shouldn't have default values.
I expect mandatory parameters not to have default values in the generated code.
Is there a solution to this issue? Perhaps I am missing something or there are additional parameters that I should be using?
Thanks
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 generation command, swagger.json, and the generated C# model such as CreateTutorialRaceBody. Check how required parameters are represented when using csharp-netcore with the unityWebRequest library. Done means generated required parameters no longer receive default values while optional parameters retain appropriate defaults.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp, openapi, unity
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100