-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
Rust validation handling #15288
Rust validation handling #15288
Conversation
Thank you, I'm glad to see support for this feature. May want to look at using the replacement garde instead (or maybe not if it isn't ready yet) |
The garde crate works for my case, so the templates are adopted now. |
@jacob-pro Is it ok now? |
It would be good to have some samples so we can see it is working? If you add some validation to this spec It should show up if you regenerate samples |
@jacob-pro Now with validation in the sample. |
Looks good to me 👍 |
rust server tests failed: https://github.com/OpenAPITools/openapi-generator/actions/runs/4798540177/jobs/8554012928?pr=15288 can you please take a look ? |
@wing328 The template is changed to handle that case. Can you please run the tests again? |
I didn't realise this when i first looked since the title was only for Rust, but does this only apply to the "rust-server" generator and not the regular Rust generator? If so please can you apply the same to the Rust generator? |
Yes, this change applies to the rust-server generation. The rust templates are for clients and are far more relaxed when it comes to data types and validation. My first impression was, this comes from the robustness principle: Be strict with what you send, be liberal what you accept, i.e. the server (rust-server) has strongly typed structs for sending data as described by the api specification, the client (rust) accepts many variants what a server may present, e.g. it puts dates into strings and leaves conversion to the calling code. But the rust-server templates generate several parts that can be used independently: models, a client and a server. Therefore I would like to leave the rust templates untouched. |
Ok makes sense |
What are the next steps to get this forward, @jacob-pro ? |
yup, all tests are important and those failures (not related to this change) have been fixed in the master already. |
the rust server tests failed: https://github.com/OpenAPITools/openapi-generator/actions/runs/4912308190/jobs/8771220846?pr=15288 can you please take a look? |
I will have a look into the failures. |
The |
I'm ok with switching back to |
Yep like I said in my original suggestion - Garde may not yet be ready for general use, feel free to switch back |
@jacob-pro @wing328 Now it is rewritten to use the validator crate. |
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
please update the samples https://github.com/OpenAPITools/openapi-generator/actions/runs/5257555438/jobs/9543332861?pr=15288 |
@wing328 Here it is. |
lgtm. let's give it a try. |
* Prevent JavaScript regex delimiter * Validation * validator dependency * validation with range * Switch to garde crate for validation * Update uuid crate * Examples * All rust-server samples * Added rule handling * Exchange garde for validator crate (rust) * Version update in samples --------- Co-authored-by: Erik Wegner <erik.wegner@regiocom.com>
PR checklist
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*
.For Windows users, please run the script in Git BASH.
master
(6.3.0) (minor release - breaking changes with fallbacks),7.0.x
(breaking changes without fallbacks)#/issues/10546