feature: generate schema from class
See original GitHub issueI see that it is possible to use a json schema to validate against. Is it also possible to generate the schema from the class?
I am currently using simpl-schema which has a great ecosystem (e,g, auto generating forms) However, I want to move away from json based schemas towards a more modern approach (i.e. class-validator package), but now I would need to define everything twice (decorators & json schema). Generating the schema from decorators would prevent a lot of duplicate code.
I don’t really care about the syntax/structure of the generated json schema since I can just write a transformer to generate the simpl-schema syntax from it.
I also don’t mind contributing if you can point me into the right direction. I would need some way to get all validator types and their arguments:
schema = {}
properties.forEach(property => {
property.validators.forEach(validator => {
schema[property.name][validator.name] = validator.value
})
})
Issue Analytics
- State:
- Created 6 years ago
- Reactions:3
- Comments:5 (2 by maintainers)

Top Related StackOverflow Question
is there any progress on this? it would be really nice to have this feature.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.