Class AsyncApiController

java.lang.Object
be.appify.prefab.asyncapi.AsyncApiController

@RestController @RequestMapping("/async-api") public class AsyncApiController extends Object
REST controller that exposes AsyncAPI documentation endpoints.
  • GET /async-api/asyncapi.json — the machine-readable AsyncAPI 2.6.0 document
  • GET /async-api — a human-readable HTML viewer backed by AsyncAPI Studio

The JSON document is generated at compile time by the Prefab annotation processor and embedded in the application JAR at META-INF/async-api/asyncapi.json. Spring property placeholders (e.g. ${topics.orders}) used as topic names in @Event annotations are resolved at runtime against the application Environment.

  • Constructor Summary

    Constructors
    Constructor
    Description
    AsyncApiController(org.springframework.core.env.Environment environment)
    Constructs a new AsyncApiController.
  • Method Summary

    Modifier and Type
    Method
    Description
    org.springframework.http.ResponseEntity<String>
    Returns the machine-readable AsyncAPI 2.6.0 JSON document with all Spring property placeholders in channel names resolved against the application environment.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • AsyncApiController

      public AsyncApiController(org.springframework.core.env.Environment environment)
      Constructs a new AsyncApiController.
      Parameters:
      environment - the Spring environment used to resolve property placeholders in topic names
  • Method Details

    • asyncApiJson

      @GetMapping(value="/asyncapi.json", produces="application/json") public org.springframework.http.ResponseEntity<String> asyncApiJson() throws IOException
      Returns the machine-readable AsyncAPI 2.6.0 JSON document with all Spring property placeholders in channel names resolved against the application environment.
      Returns:
      the AsyncAPI JSON document, or 404 if the file was not generated, or 500 if a placeholder cannot be resolved
      Throws:
      IOException - if the document cannot be read from the classpath