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

[generalized validation] Generate code validation rules based on spec for every supported language #2079

Open
2 tasks done
slavaGanzin opened this issue Jul 25, 2024 · 1 comment
Labels
enhancement New feature or request

Comments

@slavaGanzin
Copy link

slavaGanzin commented Jul 25, 2024

Why do we need this improvement?

Spec is great, but if it's validated on a gateway level it creates possibility of developer sending message and gateway silently rejecting it. Plus, when there is a version difference between validation (on a gateway) and a client (on developer side) it could create situations where developer sending proper message (according to his spec) and gateway rejecting it. This decrease development cycle speed

How will this change help?

Developer will get exception immediately after passing wrong arguments.

Screenshots

No response

How could it be implemented/designed?

There is pydantic rules for python already, but for JS/TS this could be done with https://github.com/colinhacks/zod or as it's done in glee with ajv: https://github.com/asyncapi/glee/blob/897d7a81946897c00b6db87ca879d308ae13d914/src/lib/util.ts#L101. It doesn't matter, but this feature should be cross-language.

I don't like that you need to enable them per language with different options, that's crazy. I was expecting that you'll have just one argument --no-validation that will disable automatic validation rules generation, and if it's not present validation rules should be forced into models. For real, there is no use for models if I can put any garbage into them.

p.s. I don't want to rise another issue, but why spec descriptions is not present in models? In languages like python, it will bring you intellisense for free

🚧 Breaking changes

Yes

👀 Have you checked for similar open issues?

  • I checked and didn't find a similar issue

🏢 Have you read the Contributing Guidelines?

Are you willing to work on this issue?

Yes I am willing to submit a PR!

@slavaGanzin slavaGanzin added the enhancement New feature or request label Jul 25, 2024
Copy link
Contributor

Welcome to AsyncAPI. Thanks a lot for reporting your first issue. Please check out our contributors guide and the instructions about a basic recommended setup useful for opening a pull request.
Keep in mind there are also other channels you can use to interact with AsyncAPI community. For more details check out this issue.

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

No branches or pull requests

1 participant