This topic was raised during the code sprint:
When we are transforming from a more relaxed schema to another more restrictive, it is possible that the result will not be compliant with the output schema, as we are not validating the output.
I took a look on how this could be implemented, and here are my thoughts about it:
- The current
validate command is a proxy to validate_mcf
- I understand that we want to keep
validate_mcf, as it is used in the pygeoapi_plugin
- Validation can be useful on its own, not only when transforming
- The commands that accept an MCF as an input are different from the commands that accept metadata in other schemas
The path I am following is:
- Add a
validate method to BaseOutputSchema
- Add
can_validate to the schema_matrix elements in get_supported_schemas
- Add
validate to the schemas click command from get_supported_schemas
- Modify the
get_supported_schemas to filter by schemas that can validate?
- Add a
validate option to the transform click command using the previous filter when calling to get_supported_schemas to build the list of choices
- If the option
validate is present, call to schema_object_output.validate(content) in transform_metadata
The questions I have are:
- What to do with
can_validate in get_supported_schemas for include_autodetect
- Should we add the filter by validate in
get_supported_schemas?
- How to generalize the
validate click command? It seems like a design decision to have differentiated the commands that accept MFC from the ones that accept metadata in other schemas, so a unification might break that principle
I will reference a branch in my fork to show all the details mentioned in this issue.
This topic was raised during the code sprint:
When we are transforming from a more relaxed schema to another more restrictive, it is possible that the result will not be compliant with the output schema, as we are not validating the output.
I took a look on how this could be implemented, and here are my thoughts about it:
validatecommand is a proxy tovalidate_mcfvalidate_mcf, as it is used in thepygeoapi_pluginThe path I am following is:
validatemethod toBaseOutputSchemacan_validateto theschema_matrixelements inget_supported_schemasvalidateto theschemasclick command fromget_supported_schemasget_supported_schemasto filter by schemas that can validate?validateoption to thetransformclick command using the previous filter when calling toget_supported_schemasto build the list of choicesvalidateis present, call toschema_object_output.validate(content)intransform_metadataThe questions I have are:
can_validateinget_supported_schemasforinclude_autodetectget_supported_schemas?validateclick command? It seems like a design decision to have differentiated the commands that accept MFC from the ones that accept metadata in other schemas, so a unification might break that principleI will reference a branch in my fork to show all the details mentioned in this issue.