-
Notifications
You must be signed in to change notification settings - Fork 166
Closed
Labels
Description
Problem description
When interacting with Guardian through the API, users can request the JSON schema that describes the expected payload for a given endpoint. However, many of these schemas are extremely large, often containing 1,000+ fields, making it difficult for users to manually construct valid payloads solely from the schema definition.
In the UI, users can automatically populate form fields with test data using the "Test" button located in the form header (available in Dry Run mode). The API currently lacks this functionality, which creates friction for developers and leads to inconsistent experiences between UI and API usage.
Requirements
- Add an API endpoint that generates an example payload based on the same logic currently used by the UI "Test" button in Dry Run mode.
- The example payload generation must follow this exact priority order:
- If a field has an
exampledefined, use that. - If no example exists, use the corresponding preset value (if available).
- If neither an example nor preset exists, generate a value based on the field's data type.
- If a field has an
- The generated payload must fully match the structure defined by the JSON schema, including nested fields.
- Ensure feature parity between UI "Test" button logic and API-generated examples.
- Preserve existing performance expectations even for very large schemas.
Definition of done
- Functionality is implemented as specified above.
- New capabilities are documented.
Acceptance criteria
- A new API endpoint is available that returns an example payload for any JSON schema-driven endpoint.
- The logic for generating example payloads matches UI "Test" button behavior exactly (example → preset → field's data type).
- The API returns a fully structured payload that adheres to the schema, regardless of size or depth.
- The output is deterministic given the same schema and presets.
- No regressions occur in existing schema-related functionality.
- All tests complete successfully with zero errors.
Reactions are currently unavailable