Skip to content

feat: wire constraint generation on form save and validate on subscri…#15918

Merged
JedrzejJanasiak merged 1 commit intomasterfrom
apim-12990-validation-resource
Mar 30, 2026
Merged

feat: wire constraint generation on form save and validate on subscri…#15918
JedrzejJanasiak merged 1 commit intomasterfrom
apim-12990-validation-resource

Conversation

@JedrzejJanasiak
Copy link
Copy Markdown
Contributor

Issue

https://gravitee.atlassian.net/browse/APIM-12990

Description

PR 3/3 — Resource layer: constraint generation on form save + submission validation.
Previous: #15864 (PR 2/3 — repository layer, constraint persistence)

This PR adds:

  • UpdateSubscriptionFormUseCase now generates constraints from GMD on every save
    (GMD → schemaGenerator.generate() → ConstraintsFactory.fromSchema() → persist)
  • SubscriptionForm.update() simplified — always replaces constraints, null-as-skip removed
  • SubscriptionValidationServiceImpl validates submitted metadata against stored constraints
    at subscription creation time (only when form exists, is enabled, and has non-empty constraints)
  • Tests for UpdateSubscriptionFormUseCase (constraint generation scenarios)
  • Tests for SubscriptionValidationServiceImpl (all guard conditions: form absent, disabled,
    empty constraints, null metadata, valid/invalid submission)
  • Portal resource test: SubscriptionFormValidationException → HTTP 400

Not in this PR (coming in following story):

  • EL-based dynamic options validation
  • Frontend integration

Additional context

The validator is intentionally "dumb" — it only validates metadata keys that have constraints
defined in the form. Metadata from other sources is passed through without validation.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request, the third in a series, introduces crucial functionality for managing and validating subscription form metadata. It ensures that whenever a subscription form is updated, its validation rules are automatically derived from the Gravitee Markdown definition and stored. Subsequently, any new subscription requests are rigorously checked against these defined rules, preventing invalid metadata submissions and improving data integrity.

Highlights

  • Constraint Generation on Form Save: The UpdateSubscriptionFormUseCase now automatically generates and persists validation constraints from Gravitee Markdown (GMD) content whenever a subscription form is saved.
  • Simplified Subscription Form Update: The SubscriptionForm.update() method has been simplified to always replace existing validation constraints with newly generated ones, removing the previous conditional update logic.
  • Subscription Metadata Validation: SubscriptionValidationServiceImpl has been enhanced to validate submitted subscription metadata against the stored form constraints during subscription creation.
  • Comprehensive Testing: New unit and integration tests have been added to cover the constraint generation in UpdateSubscriptionFormUseCase and various validation scenarios in SubscriptionValidationServiceImpl, including a portal resource test for SubscriptionFormValidationException mapping to an HTTP 400 Bad Request.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request effectively wires up constraint generation for subscription forms on save and adds validation for subscription metadata against these constraints. The changes in UpdateSubscriptionFormUseCase to generate constraints from GMD and in SubscriptionValidationServiceImpl to perform the validation are clear and well-implemented. The simplification of SubscriptionForm.update is a good improvement for code clarity. The accompanying tests are comprehensive, covering various scenarios including edge cases for both the use case and the validation service, and ensuring correct exception handling at the resource layer. The implementation aligns perfectly with the description, and I found no issues with the changes.

@JedrzejJanasiak JedrzejJanasiak force-pushed the apim-12990-validation-resource branch from 1ab6a9f to 64897da Compare March 24, 2026 13:52
@JedrzejJanasiak JedrzejJanasiak force-pushed the apim-12990-validation-repo branch 2 times, most recently from 80333cf to 699c2e2 Compare March 24, 2026 16:09
@JedrzejJanasiak JedrzejJanasiak force-pushed the apim-12990-validation-resource branch from 64897da to b837a70 Compare March 24, 2026 16:13
@JedrzejJanasiak JedrzejJanasiak force-pushed the apim-12990-validation-repo branch from 699c2e2 to 4ccfcdc Compare March 24, 2026 18:37
@JedrzejJanasiak JedrzejJanasiak force-pushed the apim-12990-validation-resource branch 2 times, most recently from c460e7a to aa83d72 Compare March 24, 2026 19:02
@JedrzejJanasiak JedrzejJanasiak force-pushed the apim-12990-validation-repo branch from 4ccfcdc to cf90c39 Compare March 25, 2026 08:45
@JedrzejJanasiak JedrzejJanasiak force-pushed the apim-12990-validation-resource branch 2 times, most recently from c954f07 to 358a877 Compare March 25, 2026 09:46
@JedrzejJanasiak JedrzejJanasiak force-pushed the apim-12990-validation-repo branch from cf90c39 to 2048132 Compare March 25, 2026 12:05
@JedrzejJanasiak JedrzejJanasiak force-pushed the apim-12990-validation-resource branch from 358a877 to d61efd4 Compare March 25, 2026 12:18
Base automatically changed from apim-12990-validation-repo to master March 25, 2026 12:58
@JedrzejJanasiak JedrzejJanasiak force-pushed the apim-12990-validation-resource branch 3 times, most recently from f075333 to 8063362 Compare March 25, 2026 13:48
@JedrzejJanasiak JedrzejJanasiak marked this pull request as ready for review March 25, 2026 14:24
@JedrzejJanasiak JedrzejJanasiak requested a review from a team as a code owner March 25, 2026 14:24
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@JedrzejJanasiak JedrzejJanasiak force-pushed the apim-12990-validation-resource branch from 8063362 to 8b03cb6 Compare March 27, 2026 16:10
@sonarqubecloud
Copy link
Copy Markdown

@JedrzejJanasiak JedrzejJanasiak merged commit 4ad3287 into master Mar 30, 2026
44 checks passed
@JedrzejJanasiak JedrzejJanasiak deleted the apim-12990-validation-resource branch March 30, 2026 07:33
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.

2 participants