Skip to content

[GO] Add assert constraints checks for complex types in the model template - #18654

Merged
wing328 merged 3 commits into
OpenAPITools:masterfrom
avivlevitski-vlz:go-add-assert-constraints-checks-for-complex-types
May 15, 2024
Merged

[GO] Add assert constraints checks for complex types in the model template#18654
wing328 merged 3 commits into
OpenAPITools:masterfrom
avivlevitski-vlz:go-add-assert-constraints-checks-for-complex-types

Conversation

@avivlevitski-vlz

@avivlevitski-vlz avivlevitski-vlz commented May 13, 2024

Copy link
Copy Markdown
Contributor

to close #18651

Add assert constraints checks for complex types in the model template.
Every nested model will be validated (if necessary according to the component schema format).

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh ./bin/configs/*.yaml
    ./bin/utils/export_docs_generators.sh
    
    (For Windows users, please run the script in Git BASH)
    Commit all changed files.
    This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
    These must match the expectations made by your contribution.
    You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*.
    IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
  • File the PR against the correct branch: master (upcoming 7.1.0 minor release - breaking changes with fallbacks), 8.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.

@antihax @grokify @kemokemo @jirikuncar @ph4r5h4d @lwj5

@avivlevitski-vlz
avivlevitski-vlz force-pushed the go-add-assert-constraints-checks-for-complex-types branch from c70a002 to d2c6f41 Compare May 13, 2024 10:43
@avivlevitski-vlz avivlevitski-vlz changed the title [GO] Implement #18651 - Add assert constraints checks for complex types in the model tem… [GO] #18651 - Add assert constraints checks for complex types in the model tem… May 13, 2024
@avivlevitski-vlz
avivlevitski-vlz force-pushed the go-add-assert-constraints-checks-for-complex-types branch from d2c6f41 to 0efed8b Compare May 13, 2024 12:33
@wing328

wing328 commented May 14, 2024

Copy link
Copy Markdown
Member

// This method traverse nested slices in a preorder fashion.
func AssertRecurseInterfaceRequired[T any](obj interface{}, callback func(T) error) error {
return AssertRecurseValueRequired(reflect.ValueOf(obj), callback)
func AssertRecurseInterface[T any](obj interface{}, callback func(T) error) error {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

is it a must to rename this function? i'm afraid this may break the usage of our existing users

same for line 49

@avivlevitski-vlz avivlevitski-vlz May 14, 2024

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Not must, it's a more generic name due to the usage of both the required and constraints

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I suggest we keep the original/old name for the time being and rename it in the upcoming 8.0.x as some users do not like these kinda breaking changes in a minor release.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

another way is to keep the old function name (underlying it's calling the new function) and mark it as deprecated

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done :)

@wing328 wing328 added this to the 7.6.0 milestone May 15, 2024
@wing328 wing328 changed the title [GO] #18651 - Add assert constraints checks for complex types in the model tem… [GO] Add assert constraints checks for complex types in the model template May 15, 2024
@wing328

wing328 commented May 15, 2024

Copy link
Copy Markdown
Member

thanks for the PR. let's give it a try

@wing328
wing328 merged commit affb6bc into OpenAPITools:master May 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[REQ][GO] Model templates not contains constraints checks for complex types

2 participants