Skip to content

Conversation

@predic8
Copy link
Member

@predic8 predic8 commented Dec 6, 2025

…o status in YAML tutorials and schemas

  • Introduced MCExcludeFromSchema annotation to allow exclusion of fields during schema generation.
  • Replaced statusCode with status across YAML tutorial and schema files for consistency.
  • Updated JsonSchemaGenerator and AttributeInfo to support exclusion logic based on the new annotation.

Summary by CodeRabbit

  • New Features
    • Added attribute option to exclude properties from generated JSON/XSD schemas; help output now marks exclusions and deprecations.
  • Bug Fixes
    • Schema generation omits attributes flagged for exclusion.
  • Deprecations
    • HTTP response field renamed from statusCode to status; legacy statusCode kept and deprecated; examples updated.
  • Documentation
    • Javadoc and generated help enhanced to surface deprecation and exclusion metadata.

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

…o `status` in YAML tutorials and schemas - Introduced `MCExcludeFromSchema` annotation to allow exclusion of fields during schema generation. - Replaced `statusCode` with `status` across YAML tutorial and schema files for consistency. - Updated `JsonSchemaGenerator` and `AttributeInfo` to support exclusion logic based on the new annotation.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 6, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds MCAttribute.excludeFromJson, exposes AttributeInfo.excludedFromJsonSchema(), makes JsonSchemaGenerator and HelpReference honor the exclusion and deprecation flags, renames ReturnInterceptor's internal statusCode → status with new accessors and deprecates the old setter, and updates many YAML examples to use status keys.

Changes

Cohort / File(s) Summary
Annotation definition
annot/src/main/java/com/predic8/membrane/annot/MCAttribute.java
Added boolean excludeFromJson() default false; and expanded Javadoc.
Attribute metadata
annot/src/main/java/com/predic8/membrane/annot/model/AttributeInfo.java
Added public excludedFromJsonSchema() method; minor Javadoc cleanup.
JSON Schema generation
annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java
Skip attributes where ai.excludedFromJsonSchema() in processMCAttributes(); minor formatting tweaks.
Help/reference output
annot/src/main/java/com/predic8/membrane/annot/generator/HelpReference.java
Emit deprecated attributes and excludeFromJson on attribute XML nodes using new inspection methods.
Javadoc/annotation utils
annot/src/main/java/com/predic8/membrane/annot/model/AbstractJavadocedInfo.java
Added JAVA_LANG_DEPRECATED constant and isDeprecated() method to detect java.lang.Deprecated.
Return interceptor refactor
core/src/main/java/com/predic8/membrane/core/interceptor/flow/ReturnInterceptor.java
Renamed private field statusCodestatus; added setStatus(int)/getStatus(); deprecated setStatusCode(int) forwards to new setter; getStatusCode() now returns status; updated response construction and docs.
Tests
core/src/test/java/com/predic8/membrane/core/config/spring/k8s/EnvelopeTest.java
Updated test YAML to use status: 200 instead of statusCode: 200.
Examples & tutorials (many YAMLs)
distribution/.../*.yaml, distribution/examples/.../apis.yaml, distribution/tutorials/.../*.yaml
Replaced statusCode: <n> with status: <n> across numerous example and tutorial YAML files to match the refactored key.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • Pay special attention to:
    • ReturnInterceptor: correct deprecation annotation, backward compatibility of setStatusCode/getStatusCode, and any serialization or config parsing relying on the old key.
    • JsonSchemaGenerator + AttributeInfo + HelpReference: ensure excluded attributes are consistently omitted from JSON Schema and XML output.
    • A sample of updated YAML examples to confirm tooling/parsers accept status in all contexts.

Possibly related PRs

Suggested reviewers

  • christiangoerdes
  • predic8

Poem

🐇 I nudge a field, a tiny hop so spry,
"Exclude me from JSON," I whisper to the sky.
Statuses renamed, examples set straight,
A tidy schema garden — carrot cake for late! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 26.09% 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 PR title accurately describes the two main changes: introducing MCExcludeFromSchema annotation and migrating statusCode to status throughout the codebase.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9be78b8 and 13e99fa.

📒 Files selected for processing (4)
  • annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java (1 hunks)
  • distribution/tutorials/getting-started/50-Short-Circuit.yaml (1 hunks)
  • distribution/tutorials/getting-started/60-SetHeader.yaml (1 hunks)
  • distribution/tutorials/getting-started/70-Template.yaml (1 hunks)

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.

@predic8 predic8 added the 7.x label Dec 6, 2025
@membrane-ci-server
Copy link

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

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

🧹 Nitpick comments (2)
annot/src/main/java/com/predic8/membrane/annot/MCExcludeFromSchema.java (1)

22-37: Align Javadoc with @Target(METHOD) (fields vs. methods)

The Javadoc states the annotation “can be applied to fields”, but @Target(METHOD) restricts usage to methods only. Either update the Javadoc to mention methods (e.g., setters) or expand the target to include FIELD if field usage is intended.

core/src/main/java/com/predic8/membrane/core/interceptor/flow/ReturnInterceptor.java (1)

35-43: Update high-level documentation to reference status as the primary option

The class Javadoc still states “The options statusCode and contentType will overwrite the values from the messages.” while the new configuration surface now uses status as the primary property (with statusCode kept only for backward compatibility). To avoid confusing users (and schema-driven tooling), it would be good to:

  • Mention status as the main option in the Javadoc (e.g., “status (preferred) and legacy statusCode…”), and
  • Keep setStatus’s Javadoc as the canonical description/default/example.

This keeps the docs aligned with the new schema and the renamed property.

Also applies to: 141-148

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6293988 and e995102.

📒 Files selected for processing (28)
  • annot/src/main/java/com/predic8/membrane/annot/MCExcludeFromSchema.java (1 hunks)
  • annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java (1 hunks)
  • annot/src/main/java/com/predic8/membrane/annot/model/AttributeInfo.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/flow/ReturnInterceptor.java (5 hunks)
  • core/src/test/java/com/predic8/membrane/core/config/spring/k8s/EnvelopeTest.java (1 hunks)
  • distribution/examples/extending-membrane/error-handling/custom-error-messages/apis.yaml (2 hunks)
  • distribution/examples/extending-membrane/if/apis.yaml (1 hunks)
  • distribution/examples/monitoring-tracing/prometheus/apis.yaml (1 hunks)
  • distribution/examples/openapi/validation-security/apis.yaml (1 hunks)
  • distribution/examples/openapi/validation-simple/apis.yaml (1 hunks)
  • distribution/examples/openapi/validation/apis.yaml (2 hunks)
  • distribution/examples/orchestration/call-authentication/apis.yaml (1 hunks)
  • distribution/examples/routing-traffic/shadowing/apis.yaml (3 hunks)
  • distribution/examples/security/ssl-tls/api-with-tls-pem/apis.yaml (1 hunks)
  • distribution/examples/security/ssl-tls/api-with-tls-pkcs12/apis.yaml (1 hunks)
  • distribution/examples/templating/json/apis.yaml (1 hunks)
  • distribution/examples/templating/xml/apis.yaml (2 hunks)
  • distribution/tutorials/advanced/10-PathParameters.yaml (1 hunks)
  • distribution/tutorials/advanced/60-if.yaml (1 hunks)
  • distribution/tutorials/advanced/70-Scripting-Groovy.yaml (1 hunks)
  • distribution/tutorials/getting-started/50-Short-Circuit.yaml (1 hunks)
  • distribution/tutorials/getting-started/60-SetHeader.yaml (1 hunks)
  • distribution/tutorials/getting-started/70-Template.yaml (1 hunks)
  • distribution/tutorials/json/20-JSONPath.yaml (1 hunks)
  • distribution/tutorials/json/60-Json-Transformation.yaml (1 hunks)
  • distribution/tutorials/xml/10-JSON-to-XML.yaml (1 hunks)
  • distribution/tutorials/xml/15-XML-to-JSON.yaml (1 hunks)
  • distribution/tutorials/xml/20-XPath.yaml (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-23T13:04:11.388Z
Learnt from: predic8 Repo: membrane/api-gateway PR: 2240 File: annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java:210-215 Timestamp: 2025-10-23T13:04:11.388Z Learning: In JsonSchemaGenerator.java, when allowForeign is true for non-list child elements, use a property named "ref" (not "$ref") with type "string" to provide IDE completion hints for Spring bean references while avoiding JSON Schema keyword collision. 

Applied to files:

  • annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java
🔇 Additional comments (28)
distribution/examples/security/ssl-tls/api-with-tls-pem/apis.yaml (1)

32-33: statusCode → status field rename looks good.

The return block correctly uses the new status field name with the HTTP 200 status code preserved.

distribution/tutorials/xml/20-XPath.yaml (1)

52-53: statusCode → status field rename looks good.

The return block correctly uses the new status field name with HTTP 200 status code preserved.

distribution/examples/security/ssl-tls/api-with-tls-pkcs12/apis.yaml (1)

33-34: statusCode → status field rename looks good.

The return block correctly uses the new status field name with HTTP 200 status code preserved.

distribution/examples/monitoring-tracing/prometheus/apis.yaml (1)

13-14: statusCode → status field renames look good.

All three return blocks correctly use the new status field name with HTTP status codes (200, 404, 500) preserved.

Also applies to: 21-22, 29-30

distribution/tutorials/getting-started/70-Template.yaml (1)

27-28: statusCode → status field rename looks good.

The return block correctly uses the new status field name with HTTP 200 status code preserved.

distribution/examples/extending-membrane/error-handling/custom-error-messages/apis.yaml (1)

14-14: Verify backward compatibility of ${statusCode} template variable references.

This file contains multiple references to ${statusCode} in template variables (lines 21, 36, 56) and conditional expressions (lines 14, 45), but per the PR summary, ReturnInterceptor renamed the internal field from statusCode to status. Confirm that the expression evaluation engine can still resolve ${statusCode} via deprecated backward-compatible accessors, or these references will break at runtime.

Also applies to: 21-21, 36-36, 45-45, 56-56

distribution/tutorials/xml/10-JSON-to-XML.yaml (1)

21-22: statusCode → status field rename looks good.

The return block correctly uses the new status field name with HTTP 200 status code preserved.

distribution/examples/templating/xml/apis.yaml (1)

14-15: statusCode → status field renames look good.

Both return blocks correctly use the new status field name with HTTP 200 status code preserved.

Also applies to: 29-30

distribution/tutorials/advanced/60-if.yaml (1)

22-22: Return block status field rename looks correct

Using status: 400 in the return interceptor is consistent with the new convention and keeps behavior identical.

distribution/examples/openapi/validation-simple/apis.yaml (1)

25-25: Consistent status field in mock backend

The switch to status: 201 in the mock proxy’s return block is consistent with the new response schema and keeps semantics unchanged.

distribution/examples/templating/json/apis.yaml (1)

18-18: Short‑circuit status rename is in line with new API

status: 200 in the return block matches the updated ReturnInterceptor configuration and preserves the 200 OK behavior.

distribution/tutorials/json/60-Json-Transformation.yaml (1)

54-54: Tutorial return status field updated appropriately

Using status: 200 in the JSON transformation tutorial aligns the sample with the new configuration model without altering behavior.

core/src/test/java/com/predic8/membrane/core/config/spring/k8s/EnvelopeTest.java (1)

85-87: Inline YAML updated to new status field

The embedded YAML in routerConfConfig now uses status: 200, consistent with the updated samples and ReturnInterceptor schema; no test logic impact beyond keeping things in sync.

distribution/tutorials/advanced/70-Scripting-Groovy.yaml (1)

20-20: Groovy scripting tutorial return status updated

The return block now correctly uses status: 200, matching the new configuration field name while keeping the example behavior identical.

distribution/examples/openapi/validation/apis.yaml (1)

33-33: Validation example mocks now use standardized status field

Both return blocks now specify status (201 and 200) instead of statusCode, which is consistent with the new ReturnInterceptor schema and other OpenAPI validation examples.

Also applies to: 56-56

distribution/tutorials/getting-started/50-Short-Circuit.yaml (1)

31-31: Getting-started short‑circuit uses new status field

The tutorial’s return block now uses status: 200, which aligns the introductory docs with the current configuration surface.

distribution/tutorials/json/20-JSONPath.yaml (1)

54-54: Status field rename is consistent and correct

status: 200 is syntactically valid and consistent with the new status convention; no further changes needed here.

distribution/tutorials/advanced/10-PathParameters.yaml (1)

25-26: Return status rename looks good

Using status: 200 under the return step matches the new API and keeps behavior unchanged.

distribution/examples/extending-membrane/if/apis.yaml (1)

71-72: Return block migration to status is consistent

The final return now uses status: 302, which aligns with the new naming while leaving existing statusCode tests/snippets intact for backward compatibility.

distribution/examples/routing-traffic/shadowing/apis.yaml (2)

37-39: Other status renames are correct

status: 201 is syntactically valid and consistent with the new convention.


46-47: Third return status rename also looks good

status: 202 is correct and keeps the original behavior.

distribution/tutorials/xml/15-XML-to-JSON.yaml (1)

20-21: XML-to-JSON tutorial return uses new status field correctly

status: 200 under the return block is correct and matches the updated schema.

distribution/examples/orchestration/call-authentication/apis.yaml (1)

48-49: Auth error response status rename is fine

Switching to status: 401 preserves semantics and aligns with the new status field naming.

annot/src/main/java/com/predic8/membrane/annot/model/AttributeInfo.java (1)

199-222: Exclusion helpers are straightforward and correct

Both isExcludedFromJsonSchema() and isExcludedFromXsdSchema() correctly consult MCExcludeFromSchema on the setter element and return the corresponding json / xsd flags; this integrates cleanly with existing getE()-based logic.

annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java (1)

174-187: JSON schema exclusion guard is correctly placed and non-invasive

Using ai.isExcludedFromJsonSchema() as an early return inside processMCAttributes cleanly ensures excluded attributes never reach createProperty, while preserving the existing special-case for id on top-level elements. This integrates well with the new MCExcludeFromSchema semantics and does not interfere with prior allowForeign/ref behavior.
Based on learnings, existing allowForeign JSON schema conventions remain unchanged.

core/src/main/java/com/predic8/membrane/core/interceptor/flow/ReturnInterceptor.java (1)

54-96: Status field rename and usage look consistent and backward compatible

Switching from statusCode to status (field, response builder, and short description) is internally consistent: getOrCreateResponse and createResponseFromRequest both use the new status field, and the short description now formats that same value. Existing flows that relied on the previous statusCode field semantics should continue to behave the same, while the new status accessors provide a clearer public API.

Also applies to: 115-116

distribution/examples/openapi/validation-security/apis.yaml (1)

27-33: YAML example now matches the new status property

Renaming statusCode to status under the return block is consistent with the updated ReturnInterceptor API and schema direction, and keeps the example aligned with the language-server schema (status being the advertised field).

distribution/tutorials/getting-started/60-SetHeader.yaml (1)

14-25: Tutorial return block correctly migrated to status

Using status: 200 in the return step is in line with the new configuration name and will work better with updated JSON schema and editor tooling, without affecting runtime behavior.

Copy link
Member

@rrayst rrayst left a comment

Choose a reason for hiding this comment

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

Ch

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: 1

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e995102 and edb472e.

📒 Files selected for processing (4)
  • annot/src/main/java/com/predic8/membrane/annot/MCAttribute.java (1 hunks)
  • annot/src/main/java/com/predic8/membrane/annot/model/AttributeInfo.java (1 hunks)
  • core/src/main/java/com/predic8/membrane/core/interceptor/flow/ReturnInterceptor.java (6 hunks)
  • distribution/examples/routing-traffic/shadowing/apis.yaml (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • distribution/examples/routing-traffic/shadowing/apis.yaml
  • core/src/main/java/com/predic8/membrane/core/interceptor/flow/ReturnInterceptor.java
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: predic8 Repo: membrane/api-gateway PR: 2240 File: annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java:210-215 Timestamp: 2025-10-23T13:04:11.388Z Learning: In JsonSchemaGenerator.java, when allowForeign is true for non-list child elements, use a property named "ref" (not "$ref") with type "string" to provide IDE completion hints for Spring bean references while avoiding JSON Schema keyword collision. 
⏰ 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 (1)
annot/src/main/java/com/predic8/membrane/annot/MCAttribute.java (1)

22-32: New exclusion flags and Javadoc look consistent with intended behavior

The added excludeFromJson() / excludeFromXsd() members and the updated class‑level Javadoc line up with how these attributes will be used in schema generation; no functional issues from this change.

Also applies to: 38-39

@predic8
Copy link
Member Author

predic8 commented Dec 6, 2025

/ok-to-test

@predic8
Copy link
Member Author

predic8 commented Dec 6, 2025

@coderabbitai review

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 6, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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: 0

🧹 Nitpick comments (1)
annot/src/main/java/com/predic8/membrane/annot/model/AttributeInfo.java (1)

197-203: Consider referencing the annotation element in Javadoc.

The implementation correctly uses the cached annotation field. The Javadoc could optionally reference MCAttribute#excludeFromJson() for better discoverability.

Example enhancement:

 /** * Determines whether the current field or method should be excluded from the JSON schema during schema generation. + * This is based on the {@link MCAttribute#excludeFromJson()} annotation element. * @return {@code true} if the field or method is excluded from the JSON schema; {@code false} otherwise. */ public boolean excludedFromJsonSchema() { return annotation != null && annotation.excludeFromJson(); }
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 195407e and 9be78b8.

📒 Files selected for processing (4)
  • annot/src/main/java/com/predic8/membrane/annot/MCAttribute.java (1 hunks)
  • annot/src/main/java/com/predic8/membrane/annot/generator/HelpReference.java (3 hunks)
  • annot/src/main/java/com/predic8/membrane/annot/model/AbstractJavadocedInfo.java (3 hunks)
  • annot/src/main/java/com/predic8/membrane/annot/model/AttributeInfo.java (1 hunks)
🧰 Additional context used
🧠 Learnings (1)
📚 Learning: 2025-10-23T13:04:11.388Z
Learnt from: predic8 Repo: membrane/api-gateway PR: 2240 File: annot/src/main/java/com/predic8/membrane/annot/generator/JsonSchemaGenerator.java:210-215 Timestamp: 2025-10-23T13:04:11.388Z Learning: In JsonSchemaGenerator.java, when allowForeign is true for non-list child elements, use a property named "ref" (not "$ref") with type "string" to provide IDE completion hints for Spring bean references while avoiding JSON Schema keyword collision. 

Applied to files:

  • annot/src/main/java/com/predic8/membrane/annot/model/AttributeInfo.java
⏰ 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). (2)
  • GitHub Check: Automated tests
  • GitHub Check: Analyze (java)
🔇 Additional comments (6)
annot/src/main/java/com/predic8/membrane/annot/MCAttribute.java (1)

22-37: LGTM! Clean annotation enhancement.

The new excludeFromJson element and enhanced Javadoc are well-structured. The default value of false ensures backward compatibility, and the inline comment clarifies the purpose.

annot/src/main/java/com/predic8/membrane/annot/generator/HelpReference.java (3)

126-126: LGTM! Consistent metadata exposure.

The addition of the deprecated attribute for element nodes properly exposes deprecation status in the generated XML reference.


202-202: LGTM! Consistent metadata exposure.

The addition of the deprecated attribute for child nodes properly exposes deprecation status in the generated XML reference.


233-234: LGTM! Complete metadata exposure for attributes.

Both the excludeFromJson and deprecated attributes are properly added to attribute nodes, providing comprehensive metadata in the generated XML reference.

annot/src/main/java/com/predic8/membrane/annot/model/AbstractJavadocedInfo.java (2)

29-29: LGTM! Well-defined constant.

The constant follows Java naming conventions and provides a clear, reusable reference to the @Deprecated annotation's fully qualified name.


56-61: LGTM! Correct deprecation detection.

The implementation correctly iterates through annotation mirrors and checks for the @Deprecated annotation using the fully qualified name comparison.

@rrayst rrayst merged commit fa03ad7 into master Dec 8, 2025
3 of 4 checks passed
@rrayst rrayst deleted the exclude-annotation-status-code branch December 8, 2025 12:44
@coderabbitai coderabbitai bot mentioned this pull request Dec 16, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

3 participants