Overhaul JSON schema generation for @types endpoint #237
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This new implementation instantiates a minimal
z3c.form
in order to allowplone.autoform
to do all the heavy lifting (particularly processing fields, fieldset directives and field move directives).This makes sure we correctly process and respect (or at least have the option to respect):
plone.autoform
directives / form hints:Basically all the heavy lifting is done in (or triggered from)
plone.autoform.base.AutoFields. updateFieldsFromSchemata()
So instead of attempting to do these complex tasks ourselves in
plone.restapi
like in the previous implementation, I instantiate a minimalz3c.form
inheriting fromAutoExtensibleForm
(and therefore indirectly fromAutoFields
), and make sureform.updateFieldsFromSchemata()
gets called on it.TODO:
@types
endpointThis also brought to the surface another issue / aspect: If we're talking about schemas with the purpose of rendering a specific form, we'll need to tell the implementation that produces the JSON schema which form this is gonna be. Different fields can be omitted / hidden / ... for edit forms than for add forms. For now I went with defaulting to delivering a schema appropriate for an add form, but I plan to further extend this implementation to support different form modes as well.