Class ChenileOpenApiCustomizer

java.lang.Object
org.chenile.http.openapi.ChenileOpenApiCustomizer
All Implemented Interfaces:
org.springdoc.core.customizers.OpenApiCustomizer

public class ChenileOpenApiCustomizer extends Object implements org.springdoc.core.customizers.OpenApiCustomizer
Publishes the contract that chenile-core resolved at startup in the OpenAPI document, for every Chenile HTTP operation (controller, annotation or JSON defined):
  • the operation id is the operation's contract name and the summary its description. An operation springdoc did not describe (for example one defined in JSON) is added;
  • a variant selected by path variables (for example a workflow event or a query name) gets its own path with those values filled in, named and described by the variant, with the variant's body schema. Such a path must not collide with an existing operation of the same method and path, or startup fails;
  • variants selected by headers or by a body field are described on the operation itself: a oneOf request body (with a discriminator for a body field) and the allowed header values;
  • the authorities each variant needs are published as x-chenile-authorities.
Body schemas come from ChenileJsonSchemaGenerator, so they match the MCP and registry contracts.
  • Field Details

  • Constructor Details

  • Method Details

    • customise

      public void customise(io.swagger.v3.oas.models.OpenAPI openApi)
      Specified by:
      customise in interface org.springdoc.core.customizers.OpenApiCustomizer
    • describe

      private void describe(io.swagger.v3.oas.models.OpenAPI openApi, OperationDefinition od)
    • findOrCreateOperation

      private io.swagger.v3.oas.models.Operation findOrCreateOperation(io.swagger.v3.oas.models.OpenAPI openApi, OperationDefinition od, io.swagger.v3.oas.models.PathItem.HttpMethod method, Set<String> pathVariables)
    • addVariantPath

      private void addVariantPath(io.swagger.v3.oas.models.OpenAPI openApi, OperationDefinition od, io.swagger.v3.oas.models.PathItem.HttpMethod method, io.swagger.v3.oas.models.Operation generic, ChenilePolymorphVariant variant, Set<String> pathVariables)
      One path per variant selected by path variables, with those variables filled in.
    • describeVariantsOnOperation

      private void describeVariantsOnOperation(io.swagger.v3.oas.models.OpenAPI openApi, OperationDefinition od, io.swagger.v3.oas.models.Operation operation, List<ChenilePolymorphVariant> variants, Set<String> pathVariables)
      Variants selected by headers or a body field: a oneOf body, allowed header values, authorities per variant.
    • documentAllowedValues

      private void documentAllowedValues(io.swagger.v3.oas.models.Operation operation, String name, Set<String> values, Set<String> pathVariables)
    • bodySchema

      private io.swagger.v3.oas.models.media.Schema<?> bodySchema(io.swagger.v3.oas.models.OpenAPI openApi, OperationDefinition od, ChenilePolymorphVariant variant)
      The schema of the operation's body for a variant (or the operation itself when variant is null): the variant's explicit JSON schema, else its type for the body parameter, else the operation's input type. Shared types become components of the document.
    • parse

      private io.swagger.v3.oas.models.media.Schema<?> parse(tools.jackson.databind.node.ObjectNode schema)
    • pathVariables

      private Set<String> pathVariables(String url)
    • pathParameter

      private io.swagger.v3.oas.models.parameters.Parameter pathParameter(String name)
    • jsonBody

      private io.swagger.v3.oas.models.parameters.RequestBody jsonBody(io.swagger.v3.oas.models.media.Schema<?> schema)
    • defaultResponses

      private io.swagger.v3.oas.models.responses.ApiResponses defaultResponses()