Skip to content

Conversation

@christiangoerdes
Copy link
Collaborator

@christiangoerdes christiangoerdes commented Dec 23, 2025

Summary by CodeRabbit

  • Documentation

    • Simplified JSON Schema validation example guide with unified setup instructions and streamlined running steps.
  • Chores

    • Reorganized example files from XML-based to YAML-based configuration structure.
    • Consolidated schema examples and removed redundant schema-mappings subdirectory.
    • Updated schema references and definitions in validation example files.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 23, 2025

Walkthrough

This PR reorganizes JSON Schema validation examples by consolidating separate example configurations, moving schema files into a unified schemas/ directory, updating example data structures to match revised validation schemas, and removing deprecated schema-mappings subdirectory with old launcher scripts and XML configuration files.

Changes

Cohort / File(s) Summary
Documentation
distribution/examples/validation/json-schema/README.md
Rewrites content to describe unified JSON Schema validation using both simple standalone validation (schema2000.json) and schemaMappings-based URN resolution (schema2001.json); removes XML-based dual-API running guide in favor of streamlined curl examples and apis.yaml configuration description.
Configuration
distribution/examples/validation/json-schema/apis.yaml
Updates jsonSchema path references from root to schemas/ subdirectory for both ports 2000 and 2001; adds explicit schemaMappings block to port 2001 API mapping URN identifiers (urn:app:base_def, urn:app:meta_def) to schema files.
Example Data
distribution/examples/validation/json-schema/good2001.json, distribution/examples/validation/json-schema/bad2001.json
Restructure from product-like object format to metadata-driven payload containing params array (with mode/retries objects) and meta object (with source/requestId fields).
Schema Definitions
distribution/examples/validation/json-schema/schemas/base.json (new), distribution/examples/validation/json-schema/schemas/meta.json, distribution/examples/validation/json-schema/schemas/schema2001.json
Add new base.json schema for BaseParameter definition; update meta.json to reduce required fields from ["source","requestId"] to ["source"] and remove minLength constraint on requestId; increase schema2001.json params minItems from 1 to 2 and update URN references from urn:app:base_parameter_def to urn:app:base_def.
Removed Schema-Mappings Example
distribution/examples/validation/json-schema/schema-mappings/ (entire directory)
Deleted legacy example directory including README.md, example JSON files (good/bad variants), launcher scripts (membrane.sh, membrane.cmd), proxies.xml configuration, and schema definitions (base-param.json, schema2000.json).
Removed Legacy Reference File
distribution/examples/validation/json-schema/proxies-old.xml (content updated)
Updated validator schema references to use schemas/ subdirectory paths and added schemaMappings block for port 2001 mapping urn:app:base_def and urn:app:meta_def to schema files.
Test Class Removal
distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/validation/JSONSchemaMappingsExampleTest.java
Deleted entire test class that validated the removed schema-mappings example configuration.
Test Updates
distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/validation/JSONSchemaValidationExampleTest.java
Removed good2001.json test block from port2001 test method; updated error pointer assertions to match new schema structure (/properties/params/minItems, /properties/meta/\$ref/properties/source/minLength, /properties/meta/\$ref/additionalProperties).

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • predic8

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Simplify jsonschema example' accurately describes the main objective of the pull request, which consolidates a dual XML-based router example into a single, streamlined schema-based setup.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch simplify-jsonschema-example

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
distribution/examples/validation/json-schema/proxies-old.xml (1)

1-39: Remove proxies-old.xml; it is deprecated in favor of apis.yaml.

The codebase has migrated to YAML-based configuration (apis.yaml), and this file is not referenced anywhere. The apis.yaml in this same directory contains identical configuration. Per the FilterExamples.java build logic, XML configuration files are removed when a YAML equivalent exists. The README.md also directs users to apis.yaml, not this file. Remove it to avoid confusion.

🧹 Nitpick comments (1)
distribution/examples/validation/json-schema/README.md (1)

31-32: Consider wrapping URLs in angle brackets.

The bare URLs trigger a markdown linting warning. While functional, wrapping them in angle brackets improves markdown formatting.

🔎 Proposed fix
-See:
-- JSON Schema: https://json-schema.org/
-- Membrane validator reference: https://membrane-api.io/docs/current/validator.html
+See:
+- JSON Schema: <https://json-schema.org/>
+- Membrane validator reference: <https://membrane-api.io/docs/current/validator.html>
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between de865be and 096e52e.

📒 Files selected for processing (22)
  • distribution/examples/validation/json-schema/README.md
  • distribution/examples/validation/json-schema/apis.yaml
  • distribution/examples/validation/json-schema/bad2001.json
  • distribution/examples/validation/json-schema/good2001.json
  • distribution/examples/validation/json-schema/proxies-old.xml
  • distribution/examples/validation/json-schema/schema-mappings/README.md
  • distribution/examples/validation/json-schema/schema-mappings/bad2000.json
  • distribution/examples/validation/json-schema/schema-mappings/bad2001.json
  • distribution/examples/validation/json-schema/schema-mappings/good2000.json
  • distribution/examples/validation/json-schema/schema-mappings/good2001.json
  • distribution/examples/validation/json-schema/schema-mappings/membrane.cmd
  • distribution/examples/validation/json-schema/schema-mappings/membrane.sh
  • distribution/examples/validation/json-schema/schema-mappings/proxies.xml
  • distribution/examples/validation/json-schema/schema-mappings/schemas/base-param.json
  • distribution/examples/validation/json-schema/schema-mappings/schemas/schema2000.json
  • distribution/examples/validation/json-schema/schema2001.json
  • distribution/examples/validation/json-schema/schemas/base.json
  • distribution/examples/validation/json-schema/schemas/meta.json
  • distribution/examples/validation/json-schema/schemas/schema2000.json
  • distribution/examples/validation/json-schema/schemas/schema2001.json
  • distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/validation/JSONSchemaMappingsExampleTest.java
  • distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/validation/JSONSchemaValidationExampleTest.java
💤 Files with no reviewable changes (12)
  • distribution/examples/validation/json-schema/schema-mappings/membrane.sh
  • distribution/examples/validation/json-schema/schema-mappings/good2001.json
  • distribution/examples/validation/json-schema/schema-mappings/good2000.json
  • distribution/examples/validation/json-schema/schema-mappings/schemas/schema2000.json
  • distribution/examples/validation/json-schema/schema-mappings/schemas/base-param.json
  • distribution/examples/validation/json-schema/schema-mappings/README.md
  • distribution/examples/validation/json-schema/schema2001.json
  • distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/validation/JSONSchemaMappingsExampleTest.java
  • distribution/examples/validation/json-schema/schema-mappings/bad2000.json
  • distribution/examples/validation/json-schema/schema-mappings/membrane.cmd
  • distribution/examples/validation/json-schema/schema-mappings/proxies.xml
  • distribution/examples/validation/json-schema/schema-mappings/bad2001.json
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-06-18T12:03:09.931Z
Learnt from: rrayst
Repo: membrane/api-gateway PR: 1906
File: core/src/test/java/com/predic8/membrane/core/openapi/validators/JsonSchemaTestSuiteTests.java:0-0
Timestamp: 2025-06-18T12:03:09.931Z
Learning: The mediaType method in the Request class throws jakarta.mail.internet.ParseException, not java.text.ParseException, making the jakarta.mail.internet.ParseException import necessary and correct in JsonSchemaTestSuiteTests.java.

Applied to files:

  • distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/validation/JSONSchemaValidationExampleTest.java
🪛 markdownlint-cli2 (0.18.1)
distribution/examples/validation/json-schema/README.md

31-31: Bare URL used

(MD034, no-bare-urls)


32-32: Bare URL used

(MD034, no-bare-urls)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (java)
🔇 Additional comments (7)
distribution/examples/validation/json-schema/schemas/schema2001.json (1)

12-15: LGTM! Schema changes align with example restructuring.

The increased minItems constraint and updated URN reference to urn:app:base_def align with the new base.json schema and demonstrate validation requirements effectively. The good2001.json example has 2 params (passes), while bad2001.json has 1 param (fails), which correctly demonstrates the validation behavior.

distribution/examples/validation/json-schema/bad2001.json (1)

1-12: LGTM! Multiple validation failures are intentional.

This "bad" example correctly demonstrates validation failures:

  1. params array has only 1 item (violates minItems: 2)
  2. meta.source is empty string (violates minLength: 1)
  3. meta.unexpected field present (violates additionalProperties: false)

These intentional violations effectively demonstrate schema validation behavior.

distribution/examples/validation/json-schema/schemas/meta.json (1)

7-17: LGTM! Validation relaxation is intentional.

Making requestId optional and removing its minLength constraint provides flexibility in the example. The schema still enforces:

  • Required source field with minLength: 1
  • No additional properties (additionalProperties: false)

This aligns with the example data where good2001.json includes requestId while bad2001.json fails on other violations.

distribution/examples/validation/json-schema/apis.yaml (1)

22-29: LGTM! Schema mappings configuration is correct.

The schemaMappings configuration properly maps URNs to their corresponding schema files:

  • urn:app:base_defschemas/base.json
  • urn:app:meta_defschemas/meta.json

This enables schema2001.json to resolve $ref URNs correctly during validation.

distribution/examples/validation/json-schema/good2001.json (1)

1-16: LGTM! Example data meets all validation requirements.

This "good" example correctly satisfies the schema:

  • params array has 2 items (meets minItems: 2)
  • meta.source is non-empty (meets minLength: 1)
  • meta.requestId is provided with valid format
  • No additional properties at root level

The data should pass validation successfully.

distribution/src/test/java/com/predic8/membrane/examples/withoutinternet/validation/JSONSchemaValidationExampleTest.java (2)

66-85: Asymmetry in test coverage: port2001() tests only the negative case.

The port2001() method only tests bad2001.json, while the good2001.json file exists but is never used. In contrast, port2000() tests both valid and invalid JSON. This creates an inconsistency in test coverage where port 2001 has no verification that it accepts valid JSON.

If this asymmetry is intentional as part of the simplification goal, please clarify in the commit message. Otherwise, consider adding the positive test case to maintain consistent coverage between the two test methods.


79-81: No changes needed. The error pointer paths correctly reference the evaluation path according to JSON Schema draft 2020-12 specification, which includes schema keywords and $ref traversal paths. This is the intended behavior of the networknt/json-schema library when validating against draft 2020-12 schemas.

predic8
predic8 previously approved these changes Dec 23, 2025
@membrane-ci-server
Copy link

This pull request needs "/ok-to-test" from an authorized committer.

@christiangoerdes christiangoerdes merged commit b2d505d into master Jan 7, 2026
4 of 5 checks passed
@christiangoerdes christiangoerdes deleted the simplify-jsonschema-example branch January 7, 2026 07:24
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.

3 participants