Skip to content

Conversation

@Haisia
Copy link

@Haisia Haisia commented Nov 9, 2025

Summary

Adds format field to @AsyncOperation.Headers.Header annotation to support AsyncAPI data type formats (e.g., int32, int64, date-time) per the AsyncAPI specification.

Changes

  • Added format attribute to @AsyncOperation.Headers.Header annotation with Javadoc
  • Implemented getFormat() helper method in AsyncAnnotationUtil
  • Updated getAsyncHeaders() to process and set format field
  • Fixed SwaggerSchemaUtil.mapSchemaObjectToSwagger() - uncommented setFormat() call that was preventing format from appearing in output
  • Added comprehensive tests for format handling
  • Updated test hash values due to header structure change

Implementation Note

During implementation, discovered that SwaggerSchemaUtil.mapSchemaObjectToSwagger() had setFormat() commented out, preventing format from appearing in the final AsyncAPI output. This has been fixed.

Testing

Tested with springwolf-kafka-example:

  • Headers with format display correctly in UI
  • AsyncAPI JSON output includes format field
  • Backward compatible (empty format = no format field)

Example:

@AsyncOperation.Headers.Header(
    name = "user-id",
    description = "User identifier", 
    format = "int32"
)

Output:

{
  "user-id": {
    "type": "string",
    "format": "int32",
    "description": "User identifier"
  }
}

Resolves #1506

…lf#1506)

- Add format field to @Header annotation with default empty string
- Implement format processing in AsyncAnnotationUtil.getAsyncHeaders()
- Add getFormat() helper method following existing pattern
- Update tests and hash values due to header structure change

The format field allows specifying AsyncAPI data type formats
(e.g., int32, int64, date-time) for header values while maintaining
type as 'string' per AsyncAPI specification.
@netlify
Copy link

netlify bot commented Nov 9, 2025

Deploy Preview for springwolf-ui canceled.

Name Link
🔨 Latest commit f34bf97
🔍 Latest deploy log https://app.netlify.com/projects/springwolf-ui/deploys/69105b715e1a9d0008fb4527

Copy link

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

Welcome to Springwolf. Thanks a lot for creating your first pull request. Please check out our contributors guide and feel free to join us on discord.

Copy link
Member

@timonback timonback left a comment

Choose a reason for hiding this comment

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

Looks great, Thank you @Haisia

We use our Kafka example also for show casing and indirectly as full integration test.
You mentioned that you used it for verification as well. Let's update the Kafka example (one header format is sufficient) to demonstrate this feature.

- Change getFormat to use resolve->filter order for consistency
- Remove unnecessary if block in getAsyncHeaders
- Add format example to AnotherProducer in kafka example"
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.

adding the option to specify datatypes and constraints for @AsyncOperation.Headers.Header in io.github.springwolf.core.asyncapi.annotations

2 participants