Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
* @param arrayItemType the OpenAPI schema type for array items
* @param format the data format which further specifies the schema type
* @param schemaTypeRef the OpenAPI schema type reference (used when the schema type is not a primitive type)
* @param nullable whether the parameter accepts {@code null} as a value, as defined by the OpenAPI schema
Comment thread
rsynek marked this conversation as resolved.
* @param constraintNameRef the constraint name reference (used when the parameter is a constraint weight or any other parameter
* related to a constraint)
*/
Expand All @@ -30,6 +31,7 @@ public record ModelConfigParameter(
SchemaType arrayItemType,
DataFormat format,
String schemaTypeRef,
boolean nullable,
String constraintNameRef) {

}
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,7 @@ private ModelConfigParameter resolveModelConfigParameter(FieldInfo fieldInfo) {
String description = null;
SchemaType type = null;
DataFormat format = null;
boolean nullable = false;
Optional<AnnotationInstance> schemaAnnotationOptional = getSchemaAnnotation(fieldInfo);
if (schemaAnnotationOptional.isPresent()) {
AnnotationInstance schemaAnnotation = schemaAnnotationOptional.get();
Expand All @@ -1450,6 +1451,8 @@ private ModelConfigParameter resolveModelConfigParameter(FieldInfo fieldInfo) {
schemaTypeAnnotationValue != null ? SchemaType.valueOf(schemaTypeAnnotationValue.asString()) : null;
AnnotationValue formatAnnotationValue = schemaAnnotation.value("format");
format = formatAnnotationValue != null ? DataFormat.fromString(formatAnnotationValue.asString()) : null;
AnnotationValue nullableAnnotationValue = schemaAnnotation.value("nullable");
nullable = nullableAnnotationValue != null && nullableAnnotationValue.asBoolean();
}

name = name != null ? name : fieldInfo.name();
Expand All @@ -1474,7 +1477,7 @@ private ModelConfigParameter resolveModelConfigParameter(FieldInfo fieldInfo) {
}

return new ModelConfigParameter(name, title, description, kind, type, arrayItemType, format, schemaTypeRef,
constraintRef);
nullable, constraintRef);
}

private DocumentationDescriptor processModelDocumentation() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ void detectModelConfigOverrides() throws IOException {
softly.assertThat(primitive.format()).isEqualTo(DataFormat.Percentage);
softly.assertThat(primitive.kind()).isEqualTo(ParameterKind.PARAMETER);
softly.assertThat(primitive.type()).isEqualTo(Schema.SchemaType.INTEGER);
softly.assertThat(primitive.nullable()).isFalse();

ModelConfigParameter primitiveArray = modelConfigDescriptor.configParameters().get(2);
softly.assertThat(primitiveArray.id()).isEqualTo("primitiveArrayParam");
Expand All @@ -97,6 +98,7 @@ void detectModelConfigOverrides() throws IOException {
softly.assertThat(string.kind()).isEqualTo(ParameterKind.PARAMETER);
softly.assertThat(string.type()).isEqualTo(Schema.SchemaType.STRING);
softly.assertThat(string.schemaTypeRef()).isNull();
softly.assertThat(string.nullable()).isTrue();
});
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public class TestdataModelConfigOverrides implements ModelConfigOverrides {

// Getters added due to serialization in tests when the extension is created (@RegisterExtension)

@Schema(description = "String parameter")
@Schema(description = "String parameter", nullable = true)
private String string;

public long getConstraintWeight() {
Expand Down
Loading