Skip to content

Fix enum storage in generated schema templates#25

Open
iiegn wants to merge 1 commit into
worldbank:mainfrom
commul:fix/schema-enum-storage
Open

Fix enum storage in generated schema templates#25
iiegn wants to merge 1 commit into
worldbank:mainfrom
commul:fix/schema-enum-storage

Conversation

@iiegn

@iiegn iiegn commented Apr 28, 2026

Copy link
Copy Markdown

Summary

Schema-generated enum fields are not stored in a way that is compatible with backend JSON Schema enum validation.

There are two related problems:

  1. Schema_template_generator generates enum-backed fields without explicitly setting enum storage to the raw enum code.
  2. The metadata editor frontend does not consistently honor enum_store_column for repeatable enum fields.

This can cause values like No [no] to be stored instead of no, which then fail JSON Schema validation against enum: ["yes", "no"].

Reproduction

  1. Create or upload a JSON Schema with a string enum field, for example:
    {
      "type": "string",
      "enum": ["yes", "no"]
    }
    
  2. Let the app generate the default template from that schema.
  3. Open a project using that generated template.
  4. Select No in the editor.
  5. Run schema validation.

Actual Behavior

Validation fails with an enum error such as:

Does not have a value in the enumeration ["yes","no"]

because the stored value is a display value like No [no] instead of the schema enum value no.

Repeatable enum fields have the same underlying problem when enum_store_column should be respected.

Expected Behavior

Schema-generated enum fields should store the raw enum code by default, so selecting "No" stores no, and schema validation passes.

Repeatable enum fields should use the same storage rule as single-value enum fields.

Fix

This PR does two things:

  1. Updates Schema_template_generator so generated enum fields:
    • use a dropdown-compatible display type
    • include enum options in the template payload
    • set enum_store_column to code
  2. Updates vue-form-input-component.js so repeatable enum fields also respect enum_store_column, instead of always storing Label [code].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant