OpenAPITools / openapi-generator

OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
https://openapi-generator.tech
Apache License 2.0
21.85k stars 6.59k forks source link

Mandatory parameters are assigned default values when generating Unity SDK using OpenAPI-Generator #15565

Open Natashkinsasha opened 1 year ago

Natashkinsasha commented 1 year ago

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

emwtur commented 1 year ago

it is causing problems for me, default parameters are NOT sent to server, even though they are required