Skip to content
Open
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nullable has been removed from OpenAPI in 3.1 so not sure we should rely on it https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just noticed that platform uses 3.1 and models use still 3.0.3 ... might be worth to address this at some point, but we might be ok to keep it as is for now. @rsynek FYI

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, I didn't know that! I took a look at the migration guide and it seems that there are other things that will also have to be changed when we migrate to 3.1. I would say to implement now as is and when we migrate, we can change everything (type arrays, examples).

* @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();
});
}
}
Loading