-
Notifications
You must be signed in to change notification settings - Fork 571
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
Generate forms from JSON Schema #1056
Comments
well I think providing a converter would be enough. PR welcomed, |
in order to keep it simple, starting by a simple converter (like I did in the above example) to the format we use would be enough, I think! |
@aitboudad awesome and yes, think a converter would be a good start. Will have a look at how this library works and JSON-schema's in general a bit more closely and try to iterate on this then :). |
I'm currently working on a generic implementation of said converter for an internal project. I'd love to contribute to this whenever we get more complete functionality. Do you have have any suggestions as I work on it on how we should incorporate it into the library (ngx-formly) itself? right now we have an external angular service that converts to formly config so if we want to use something other than json-schema at some point we can. Thanks |
Interestingly, I have an internal project with similar goals. I have some additional use cases I'm trying to accomplish as well:
The project is currently on hold but I will report back with some developments. |
@kenisteward For now I was thinking of developing something similar as well. A service which can convert JSON-schema to a config you can plug into this library. Where specifically I think the ultimate goal would be to meaningfully support all of the current version, draft-07. But a smaller subset might be fine as a start. Either way I agree that it would be interesting to know the desired format for the contribution so that we could maybe start on a PR. I suggest a service named Assume this JSON-schema logic should be in the @samtsai Including internationalization through A few things came up so might take a week or so for me to really get into this but still interested in pitching in. Before I, or anyone else, creates a PR it would however be good to get some feedback on the format. |
just added an initial work in #1085 which cover the basic usages (80%) see the demo https://stackblitz.com/edit/angular-xvevwe |
@aitboudad would you like me to work with you on this to cover the rest of the cases? |
…lementation fix #1056 Triggered by commit: de63fef Travis build: https://travis-ci.org/formly-js/ngx-formly/builds/411792028
initial support landed in the first step is to add a unit test for FormlyJsonschema service. @kenisteward yes I'm waiting your PRs and anyone willing to participate :) |
@aitboudad do the changes that were implemented handle most of draft 7 or 8? Just checking for future reference. |
@kenisteward that was based on draft 7, the features that are handled are:
|
custom validation not implemented yet and the stackblitz example is outdated, the latest version can be found in the following link: https://formly.dev/examples/advanced/json-schema |
@aitboudad do we want custom validation in iteration one? Should I worry about implementing it? Do you have an idea of how you want it done for the service? I ask because I'm trying to avoid double work (implementing my version of custom validation then later having to restructure for this library's formal version of it) |
it's all about experiment, implement your version and when you think it's good enough to be part of the core then send a proposal. |
@aitboudad As an update for custom validations I'm currently following It looks like it will be in spec 09 or so. I'm hoping to implement extension earlier as I need this feature in jsonSchema basically yesterday. In the meantime, since I've finally been properly assigned to our project for handling forms generation in house I can work on the current array implementation / unit tests. |
Added Tests for full coverage of current covered features Added support for minimum/maximum Added todo for things needed to be supported in the future Added logic to support key hierarchy so configs can be rearranged closes formly-js/ngx-formly/#1056
a little progress in |
I'm submitting a ... (check one with "x")
Current behavior
If you want to dynamically create forms from JSON saved in your database you currently need to define each field specifically for this form.
Expected behavior
For just a form with validation and some basic vertical layout you add a JSON schema containing all the fields in the forms and how they should be validated. Where validation could either be done through Angular Reactive forms or using a JSON schema validator like
ajv
.Minimal reproduction of the problem with instructions
There are a few other Angular form libraries similar but less popular and stable that instead use JSON schema's
Also some older but more popular versions in Angular.js, JQuery and React versions.
What is the motivation / use case for changing the behavior?
JSON schema's can be used for validation on the server, be it through
ajv
when accepting the request from the client or using JSON schemas for validation in MongoDB.More than anything it's also a standardized way to describe objects and validation so there might be some already familiar with how to do it using this format.
Our particular use-case has been crafting dozens of smaller forms with JSON schema's. Using angular2-json-schema-form for a while now to create forms from them. But with that library being a bit unstable and showing very little progress we're considering our options between trying to support further development of that library or moving over to another library, like this library.
Is this a feasible direction for this library to go towards? And are you interested in taking it down that path? As an alternative to the current structure. And in either case, would PRs to implement this functionality be accepted (given acceptable quality)?
An alternate solution, if the answer is no, would be to try to make some kind of logic that converts JSON schema to the format you use in this library. As it stands we'd probably take some time to investigate that option further.
Either way, very impressed by this library 🙂.
The text was updated successfully, but these errors were encountered: