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
oneOfrequest body (with adiscriminatorfor a body field) and the allowed header values; - the authorities each variant needs are published as
x-chenile-authorities.
ChenileJsonSchemaGenerator, so they match the MCP and registry contracts.-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final Stringprivate static final Stringprivate final ChenileConfigurationprivate final tools.jackson.databind.ObjectMapperprivate static final Patternprivate final ChenilePolymorphInitializerprivate final ChenileJsonSchemaGeneratorprivate static final String -
Constructor Summary
ConstructorsConstructorDescriptionChenileOpenApiCustomizer(ChenileConfiguration chenileConfiguration, ChenileJsonSchemaGenerator schemaGenerator, ChenilePolymorphInitializer polymorphInitializer) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddVariantPath(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.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.voidcustomise(io.swagger.v3.oas.models.OpenAPI openApi) private io.swagger.v3.oas.models.responses.ApiResponsesprivate voiddescribe(io.swagger.v3.oas.models.OpenAPI openApi, OperationDefinition od) private voiddescribeVariantsOnOperation(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.private voiddocumentAllowedValues(io.swagger.v3.oas.models.Operation operation, String name, Set<String> values, Set<String> pathVariables) private io.swagger.v3.oas.models.OperationfindOrCreateOperation(io.swagger.v3.oas.models.OpenAPI openApi, OperationDefinition od, io.swagger.v3.oas.models.PathItem.HttpMethod method, Set<String> pathVariables) private io.swagger.v3.oas.models.parameters.RequestBodyjsonBody(io.swagger.v3.oas.models.media.Schema<?> schema) private io.swagger.v3.oas.models.media.Schema<?> parse(tools.jackson.databind.node.ObjectNode schema) private io.swagger.v3.oas.models.parameters.ParameterpathParameter(String name) pathVariables(String url)
-
Field Details
-
APPLICATION_JSON
- See Also:
-
AUTHORITIES
- See Also:
-
VARIANT
- See Also:
-
PATH_VARIABLE
-
chenileConfiguration
-
schemaGenerator
-
polymorphInitializer
-
objectMapper
private final tools.jackson.databind.ObjectMapper objectMapper
-
-
Constructor Details
-
ChenileOpenApiCustomizer
public ChenileOpenApiCustomizer(ChenileConfiguration chenileConfiguration, ChenileJsonSchemaGenerator schemaGenerator, ChenilePolymorphInitializer polymorphInitializer)
-
-
Method Details
-
customise
public void customise(io.swagger.v3.oas.models.OpenAPI openApi) - Specified by:
customisein interfaceorg.springdoc.core.customizers.OpenApiCustomizer
-
describe
-
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
-
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
-
pathParameter
-
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()
-
CHENILE