Class MirrorBasedOpenApiExtension

java.lang.Object
io.domainlifecycles.swagger.v3.MirrorBasedOpenApiExtension

public class MirrorBasedOpenApiExtension extends Object
For all special DLC domain object types (entities, valueObject, identities) some Open API extensions are performed, to make the Open API description of controller interfaces match the default mapping behaviour of the DLC Jackson extension.

Identity types which are referenced from entities or value objects are "folded" in their mapping behaviour by the DLC Jackson extension. Jackson default behaviour would read and write only structures like:

{ "identityRef": { "value": "idValue" } }

This is simplified by to: { "identityRef": "idValue" }

In the same manner so called "singleValued" value object references are folded. This Open API extension, makes the api doc fit to that behaviour accordingly.

Also, id value fields are added to the API documentation of identity types. Regular Spring docs behaviour ignores those fields and gives Open API consumers wrong information. Primary identity properties are not required (for creating endpoints POST and PUT), that's why they are marked as not required.

The folding is also applied by to path and query parameters on API endpoints and hereby is corrected in the API documentation.
  • Constructor Details

    • MirrorBasedOpenApiExtension

      public MirrorBasedOpenApiExtension()
      This extension modifies and extends the Open API description for all DLC specific domain object classes, which are managed by the given Domain.
  • Method Details

    • extendOpenAPISchemaForDLCTypes

      public void extendOpenAPISchemaForDLCTypes(io.swagger.v3.oas.models.OpenAPI openAPI, String... entitiesWithExternallyProvidedIds)
      Starting point for all Open API specific extensions and corrections by this class.
      Parameters:
      openAPI - OpenAPI instance to be extended
      entitiesWithExternallyProvidedIds - array of full qualified class names of entities which require primary identities