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

make function_call optional #46

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

gaspardpetit
Copy link

The new parameter function_call can be one of three cases:

  1. an enum of value none or auto
  2. an object with a name
  3. null (since it can be omitted)

Without this fix, api generators like NSwag will mark this field as non nullable, causing resulting in API error when sending function_call: none without any function being defined, for example.

@schnerd
Copy link
Collaborator

schnerd commented Jun 15, 2023

The API does not accept a null value here (feel free to test it). Can the generator not just skip passing the property in this case?

@gaspardpetit
Copy link
Author

I agree with your objection, I will see if using nullable: true on the function_call parameter works

@gaspardpetit
Copy link
Author

gaspardpetit commented Jun 16, 2023

With NSwag, setting optional: true is not enough. A non-null object is defined with default value. setting nullable: true correctly results in an optional (nullable) object. In a way, this is an NSwag issue - it also fails to correctly handle the polymorphism between an enum and an object for this field.

I have flagged this as an issue in NSwag (RicoSuter/NSwag#4459), but if others are are experiencing the same problems with different code generator, it might be worth considering applying this fix unless it results in other code generators to generate the field with null of course

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants