-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(core): document primitive types using envelope class and AsyncAp…
…iPayload marker GH-377
- Loading branch information
Showing
5 changed files
with
131 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
...a/io/github/stavshamir/springwolf/asyncapi/scanners/channels/payload/AsyncApiPayload.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// SPDX-License-Identifier: Apache-2.0 | ||
package io.github.stavshamir.springwolf.asyncapi.scanners.channels.payload; | ||
|
||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncListener; | ||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncOperation; | ||
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.operationdata.annotation.AsyncPublisher; | ||
|
||
import java.lang.annotation.Inherited; | ||
import java.lang.annotation.Retention; | ||
import java.lang.annotation.RetentionPolicy; | ||
import java.lang.annotation.Target; | ||
|
||
import static java.lang.annotation.ElementType.FIELD; | ||
|
||
/** | ||
* Marker interface to indicate the actual payload class in envelop wrapper classes. | ||
* <p> | ||
* Since primitive data types cannot be documented directly (like String, Integer, etc.), an envelope class is needed: | ||
* <pre>{@code | ||
* public class StringEnvelop { | ||
* @AsyncApiPayload | ||
* @Schema(description = "Payload description using @Schema annotation", maxLength = 10) | ||
* String payload; | ||
* } | ||
* }</pre> | ||
* <p> | ||
* In case the signature of the listener/publisher method can not be changed to use the envelope class, | ||
* the envelope class can be set as {@link AsyncOperation#payloadType()} | ||
* in the {@link AsyncListener} and/or {@link AsyncPublisher} annotation | ||
*/ | ||
@Retention(RetentionPolicy.RUNTIME) | ||
@Target({FIELD}) | ||
@Inherited | ||
public @interface AsyncApiPayload {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"StringEnvelop" : { | ||
"maxLength" : 10, | ||
"type" : "string", | ||
"description" : "The payload in the envelop", | ||
"example" : "string" | ||
} | ||
} |