Package org.springdoc.core.utils
Class SchemaUtils
java.lang.Object
org.springdoc.core.utils.SchemaUtils
The type Validation utils.
- Author:
- dyun
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe constant ANNOTATIONS_FOR_NULLABLE.The constant ANNOTATIONS_FOR_REQUIRED.static final BooleanThe constant JAVA_FIELD_NULLABLE_DEFAULT. -
Constructor Summary
ConstructorsConstructorDescriptionSchemaUtils(Optional<SpringDocKotlinUtils> kotlinUtilsOptional) The constructor. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanannotatedNotNull(List<Annotation> annotations) Is annotated notnull.static voidapplyValidationsToSchema(io.swagger.v3.oas.models.media.Schema<?> schema, List<Annotation> annotations, String openapiVersion) Apply validations to schema. the annotation order effects the result of the validation.booleanfieldNullable(Field field) Is field nullable. java default is nullableJAVA_FIELD_NULLABLE_DEFAULTbooleanfieldRequired(Field field, io.swagger.v3.oas.annotations.media.Schema schema, io.swagger.v3.oas.annotations.Parameter parameter) Is field required.static BooleanswaggerRequired(io.swagger.v3.oas.annotations.media.Schema schema, io.swagger.v3.oas.annotations.Parameter parameter) Is swagger required. it may returnnullif not specified require value or modestatic booleanswaggerVisible(io.swagger.v3.oas.annotations.media.Schema schema, io.swagger.v3.oas.annotations.Parameter parameter) Is swagger visible.
-
Field Details
-
JAVA_FIELD_NULLABLE_DEFAULT
The constant JAVA_FIELD_NULLABLE_DEFAULT. -
ANNOTATIONS_FOR_REQUIRED
The constant ANNOTATIONS_FOR_REQUIRED. -
ANNOTATIONS_FOR_NULLABLE
The constant ANNOTATIONS_FOR_NULLABLE.
-
-
Constructor Details
-
SchemaUtils
The constructor.- Parameters:
kotlinUtilsOptional- the kotlin utils optional
-
-
Method Details
-
swaggerVisible
public static boolean swaggerVisible(@Nullable io.swagger.v3.oas.annotations.media.Schema schema, @Nullable io.swagger.v3.oas.annotations.Parameter parameter) Is swagger visible.- Parameters:
schema- the schemaparameter- the parameter- Returns:
- the boolean
-
swaggerRequired
@Nullable public static Boolean swaggerRequired(@Nullable io.swagger.v3.oas.annotations.media.Schema schema, @Nullable io.swagger.v3.oas.annotations.Parameter parameter) Is swagger required. it may returnnullif not specified require value or mode- Parameters:
schema- the schemaparameter- the parameter- Returns:
- the boolean or
null - See Also:
-
Parameter.required()Schema.required()Schema.requiredMode()
-
annotatedNotNull
Is annotated notnull.- Parameters:
annotations- the field annotations- Returns:
- the boolean
-
fieldNullable
Is field nullable. java default is nullableJAVA_FIELD_NULLABLE_DEFAULT- Parameters:
field- the field- Returns:
- the boolean
-
fieldRequired
public boolean fieldRequired(Field field, io.swagger.v3.oas.annotations.media.Schema schema, io.swagger.v3.oas.annotations.Parameter parameter) Is field required.- Parameters:
field- the fieldschema- the schemaparameter- the parameter- Returns:
- the boolean
- See Also:
-
Parameter.required()Schema.required()Schema.requiredMode()
-
applyValidationsToSchema
public static void applyValidationsToSchema(io.swagger.v3.oas.models.media.Schema<?> schema, List<Annotation> annotations, String openapiVersion) Apply validations to schema. the annotation order effects the result of the validation.- Parameters:
schema- the schemaannotations- the annotationsopenapiVersion- the openapi version
-