Skip to content

Conversation

@daveshanley
Copy link
Member

@daveshanley daveshanley commented Dec 18, 2025

I should have done this at the start, but this is a clean way to add capability, without breaking any consumers, a backward compatible upgrade.

All capable high level objects that can be rendered inline, now support the ability to pass a context as a non breaking upgrade.

This is to allow async rendering in a fully deterministic way. Addresses daveshanley/vacuum#768

I should have done this at the start, but this is a clean way to add capability, without breaking any consumers, a backward compatible upgrade.
@codecov
Copy link

codecov bot commented Dec 18, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.58%. Comparing base (2af490a) to head (e08c5e5).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #488      +/-   ##
==========================================
+ Coverage   99.57%   99.58%   +0.01%     
==========================================
  Files         175      175              
  Lines       21532    21641     +109     
==========================================
+ Hits        21441    21552     +111     
+ Misses         57       56       -1     
+ Partials       34       33       -1     
Flag Coverage Δ
unittests 99.58% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds context-aware versions of inline rendering methods to support deterministic async rendering and prevent false-positive circular reference detection in concurrent scenarios. The implementation introduces the InlineRenderContext type for isolated cycle tracking per render call-chain, replacing the previous global tracker approach. This is a backward-compatible upgrade that addresses issue #768.

Key changes:

  • Introduces InlineRenderContext for isolated cycle detection during concurrent rendering
  • Adds MarshalYAMLInlineWithContext methods to all high-level objects supporting inline rendering
  • Updates NodeBuilder to support context-aware rendering with the new RenderableInlineWithContext interface

Reviewed changes

Copilot reviewed 30 out of 30 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
datamodel/high/base/schema_proxy.go Adds InlineRenderContext type and updates SchemaProxy with context-aware rendering support
datamodel/high/base/schema.go Adds context-aware rendering methods to Schema type
datamodel/high/base/example.go Adds MarshalYAMLInlineWithContext method to Example type
datamodel/high/base/schema_test.go Adds test for error path in RenderInlineWithContext
datamodel/high/base/schema_proxy_test.go Updates existing tests to use context-aware methods and adds new context isolation tests
datamodel/high/base/example_test.go Adds tests for context-aware example rendering
datamodel/high/node_builder.go Adds RenderableInlineWithContext interface and updates rendering logic to support context-aware methods
datamodel/high/node_builder_test.go Adds comprehensive tests for context-aware rendering behavior and fallback logic
datamodel/high/shared.go Adds RenderInlineWithContext helper function
datamodel/high/shared_test.go Adds tests for the new RenderInlineWithContext helper
datamodel/high/v3/security_scheme.go Adds context-aware rendering to SecurityScheme
datamodel/high/v3/security_scheme_test.go Adds tests for context-aware security scheme rendering
datamodel/high/v3/response.go Adds context-aware rendering to Response
datamodel/high/v3/response_test.go Adds tests for context-aware response rendering
datamodel/high/v3/request_body.go Adds context-aware rendering to RequestBody
datamodel/high/v3/request_body_test.go Adds tests for context-aware request body rendering
datamodel/high/v3/path_item.go Adds context-aware rendering to PathItem
datamodel/high/v3/path_item_test.go Adds tests for context-aware path item rendering
datamodel/high/v3/parameter.go Adds context-aware rendering to Parameter
datamodel/high/v3/parameter_test.go Adds tests for context-aware parameter rendering
datamodel/high/v3/media_type.go Adds context-aware rendering to MediaType
datamodel/high/v3/media_type_test.go Adds test for context-aware media type rendering
datamodel/high/v3/link.go Adds context-aware rendering to Link with minor comment edit
datamodel/high/v3/link_test.go Adds tests for context-aware link rendering
datamodel/high/v3/header.go Adds context-aware rendering to Header with minor comment edits
datamodel/high/v3/header_test.go Adds tests for context-aware header rendering
datamodel/high/v3/encoding.go Adds context-aware rendering to Encoding
datamodel/high/v3/encoding_test.go Adds test for context-aware encoding rendering
datamodel/high/v3/callback.go Refactors to use internal method for context-aware rendering support
datamodel/high/v3/callback_test.go Adds tests for context-aware callback rendering

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.


// CreateLinkRef creates a Link that renders as a $ref to another link definition.
// This is useful when building OpenAPI specs programmatically and you want to reference
// This is useful when building OpenAPI specs programmatically, and you want to reference
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

Inconsistent punctuation in comment. The comment for CreateLinkRef adds a comma after "programmatically" which differs from the other similar CreateXRef functions. For consistency with other CreateXRef functions in the codebase, remove the comma.

Suggested change
// This is useful when building OpenAPI specs programmatically, and you want to reference
// This is useful when building OpenAPI specs programmatically and you want to reference

Copilot uses AI. Check for mistakes.

// CreateHeaderRef creates a Header that renders as a $ref to another header definition.
// This is useful when building OpenAPI specs programmatically and you want to reference
// This is useful when building OpenAPI specs programmatically, and you want to reference
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

Inconsistent punctuation in comment. The comment for CreateHeaderRef adds a comma after "programmatically" which differs from the other similar CreateXRef functions. For consistency with other CreateXRef functions in the codebase, remove the comma.

Suggested change
// This is useful when building OpenAPI specs programmatically, and you want to reference
// This is useful when building OpenAPI specs programmatically and you want to reference

Copilot uses AI. Check for mistakes.
)

// Header represents a high-level OpenAPI 3+ Header object that is backed by a low-level one.
// Header represents a high-level OpenAPI 3+ Header object backed by a low-level one.
Copy link

Copilot AI Dec 18, 2025

Choose a reason for hiding this comment

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

Inconsistent wording in comment. Changed from "that is backed by" to "backed by", but this is inconsistent with the comment change style. The original formulation "that is backed by" is grammatically correct and clearer. Consider keeping the original phrasing for better readability.

Suggested change
// Header represents a high-level OpenAPI 3+ Header object backed by a low-level one.
// Header represents a high-level OpenAPI 3+ Header object that is backed by a low-level one.

Copilot uses AI. Check for mistakes.
@daveshanley daveshanley merged commit 0a46d38 into main Dec 18, 2025
10 checks passed
@daveshanley daveshanley deleted the v0.30.2 branch December 19, 2025 15:52
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