Skip to content

Empty value problem again (OpenAPI 3.0.3) #3217

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

Closed
Ziggizag opened this issue Mar 27, 2023 · 3 comments
Closed

Empty value problem again (OpenAPI 3.0.3) #3217

Ziggizag opened this issue Mar 27, 2023 · 3 comments
Labels

Comments

@Ziggizag
Copy link

Ziggizag commented Mar 27, 2023

Hi!

I read:

"In PR #1573, targeted for the 3.0.2 patch revision, we have made use of allowEmptyValue NOT RECOMMENDED"

So, what is the right way to declare the API where:

  • passing a given request body parameter with explicit value, updates the respected property on the server side.
  • passing a given request body parameter with an "empty" string leaves the respected property intact on the server side.

Of course - for security reasons, I don't want to declare additionalProperties: true.

Any suggestions?

@MikeRalphson
Copy link
Member

MikeRalphson commented Mar 29, 2023

Probably best to explicitly set the maxLength of your parameter to 0 if it is a string. You will have to document the intent of zero-length parameters and the effect it has within your API (i.e. leaving the value intact rather than emptying it).

@Ziggizag
Copy link
Author

Ziggizag commented Mar 29, 2023

I have finally solved that this way:

status:
  description: Employee's activity status. 1 = active, 0 = inactive. You may leave it empty if it is supposed to be left intact.
  oneOf:
       - type: integer
          enum: [0, 1]
       - type: string
          maxLength: 0

@MikeRalphson
Copy link
Member

Thanks - your solution will be searchable for others hitting the same problem.

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

No branches or pull requests

2 participants