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

handle documented cases in Schema annotation #31

Merged
merged 2 commits into from
Oct 13, 2024

Conversation

NecroKote
Copy link
Contributor

@NecroKote NecroKote commented Oct 11, 2024

  • minLength and maxLength are ignored if the value is below 0
  • format is included only if it's not blank

Closes #29

- `minLength` and `maxLength` are ignored if the value is below 0
- `minLength` and `maxLength` are not included for anything other than `string` type
- `format` is included only if it's not blank
Copy link
Contributor

@rmcmk rmcmk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey -- nice fix. Just wanted to point out there are a two more @Schema fields that kenerator supports, with non-respected ignore conditions. Apologies, I probably should have stated all affected schema attributes in #29

    /**
     * Sets the maximum numeric value for a property.  Ignored if the value is an empty string.
     *
     * @return the maximum value for this schema
     **/
    String maximum() default "";
    
    /**
     * Sets the minimum numeric value for a property.  Ignored if the value is an empty string or not a number.
     *
     * @return the minimum value for this schema
     **/
    String minimum() default "";

On a side note, ignored if the value is an empty string or not a number. is only stated on minimum but is likely the case for both.

@NecroKote
Copy link
Contributor Author

re: minimum and maximum - those are already covered by existing .filter { it.isNotBlank() }
At least for the "Ignored if the value is an empty string" part

…han string type

original commit contained an error, but also for more sophisticated cases it's not clear how to determine resulting type
@NecroKote NecroKote force-pushed the bugfix/29-ignore-documented-cases branch from e2f52a4 to 06f69ce Compare October 11, 2024 14:49
@rmcmk
Copy link
Contributor

rmcmk commented Oct 11, 2024

🤦 Looked at this code half a dozen times and missed that LOL. Guess that only leaves the number validation bit. Not sure if that is necessary, though.

@SMILEY4
Copy link
Owner

SMILEY4 commented Oct 12, 2024

Looks good to me 👍 Thank you!
If its ready i'll merge it.

@NecroKote
Copy link
Contributor Author

Please do!

@SMILEY4 SMILEY4 merged commit eef0c5c into SMILEY4:develop Oct 13, 2024
2 checks passed
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.

Swagger @Schema annotation: Documented ignore conditions not respected by SwaggerSchemaAnnotationStep
3 participants