Skip to content

Conversation

@EricWittmann
Copy link
Member

Summary

  • Fixed Maven plugin to correctly set content-type to application/x-yaml for YAML files during artifact registration
  • Added test coverage to verify content-type is preserved for both YAML AsyncAPI files and JSON Avro schemas
  • Added integration test for AsyncAPI 3.0 with Avro references to reproduce the user's scenario

Root Cause

When using the Maven plugin with autoRefs enabled, the plugin determined the correct content-type from the file extension but failed to set it on the artifact object before registration. This caused the registration code to default to application/json, resulting in YAML content being registered with the wrong content-type.

Changes Made

Maven Plugin Fix (RegisterRegistryMojo.java:177-180):

  • After determining content-type from file extension, now sets it on the artifact object if not explicitly provided by user
  • Ensures YAML files (.yml, .yaml) are registered with application/x-yaml
  • Preserves user-specified content-types (doesn't override explicit values)

Test Coverage (RegisterAsyncApiAvroAutoRefsTest.java):

  • Enhanced test to capture and verify content-type headers sent during registration
  • Validates AsyncAPI YAML files are registered with application/x-yaml
  • Validates Avro schema files are registered with application/json

Integration Test (GroupsResourceTest.java):

  • Added test case using AsyncAPI 3.0.0 with Avro references (matching user's setup)
  • Verifies YAML content is preserved and parseable with ?references=REWRITE
  • Includes test resources: asyncapi-shopping-cart.yml and avro/ShoppingCartCreated.avsc

Related Issue

Fixes #6712

Test Plan

  • Run RegisterAsyncApiAvroAutoRefsTest to verify Maven plugin sets correct content-types
  • Run GroupsResourceTest#testGetArtifactVersionWithReferencesYamlContentType to verify YAML handling
  • Test with AsyncAPI 3.0.0 YAML files containing Avro references
  • Verify YAML files are registered as application/x-yaml not application/json

Fixes #6712 - The Maven plugin was not setting the content-type on artifacts
when using autoRefs, causing YAML files to be registered with application/json
instead of application/x-yaml. This led to JSON parse errors when the registry
tried to process YAML content.
@EricWittmann EricWittmann merged commit db25eea into main Jan 6, 2026
30 checks passed
@EricWittmann EricWittmann deleted the fix/maven-plugin-yaml-content-type branch January 6, 2026 12:37
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.

Support for a cannonical URL that resolves relative $refs between artifacts

2 participants