Class SpecPropertiesCustomizer

java.lang.Object
org.springdoc.core.customizers.SpecPropertiesCustomizer
All Implemented Interfaces:
GlobalOpenApiCustomizer, OpenApiCustomizer

public class SpecPropertiesCustomizer extends Object implements GlobalOpenApiCustomizer
Allows externalizing strings in generated openapi schema via properties that follow conventional naming similar or identical to openapi schema

To set value of a string in schema, define an application property that matches the target node with springdoc.spec-properties prefix.

Sample supported properties for api-info customization:

  • springdoc.spec-properties.info.title - to set title of api-info
  • springdoc.spec-properties.info.description - to set description of api-info
  • springdoc.spec-properties.info.version - to set version of api-info
  • springdoc.spec-properties.info.termsOfService - to set terms of service of api-info

Sample supported properties for components customization:

  • springdoc.spec-properties.components.User.description - to set description of User model
  • springdoc.spec-properties.components.User.properties.name.description - to set description of 'name' property
  • springdoc.spec-properties.components.User.properties.name.example - to set example of 'name' property

Sample supported properties for paths/operationIds customization:

  • springdoc.spec-properties.paths.{operationId}.description - to set description of {operationId}
  • springdoc.spec-properties.paths.{operationId}.summary - to set summary of {operationId}

Support for groped openapi customization is similar to the above, but with a group name prefix. E.g.

  • springdoc.spec-properties.{group-name}.info.title - to set title of api-info
  • springdoc.spec-properties.{group-name}.components.User.description - to set description of User model
  • springdoc.spec-properties.{group-name}.paths.{operationId}.description - to set description of {operationId}
Author:
Anton Tkachenko [email protected], bnasslahsen
  • Constructor Details

    • SpecPropertiesCustomizer

      public SpecPropertiesCustomizer(SpringDocConfigProperties springDocConfigProperties)
      Instantiates a new Spec properties customizer.
      Parameters:
      springDocConfigProperties - the spring doc config properties
    • SpecPropertiesCustomizer

      public SpecPropertiesCustomizer(io.swagger.v3.oas.models.OpenAPI openApiProperties)
      Instantiates a new Spec properties customizer.
      Parameters:
      openApiProperties - the open api properties
  • Method Details

    • customise

      public void customise(io.swagger.v3.oas.models.OpenAPI openApi)
      Description copied from interface: OpenApiCustomizer
      Customise.
      Specified by:
      customise in interface OpenApiCustomizer
      Parameters:
      openApi - the open api