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 @@ -207,7 +207,7 @@ private static void assignType(Schema swaggerSchema, SchemaObject.SchemaObjectBu
String schemaType = swaggerSchema.getType();
if (!types.contains(schemaType)) {
// required while swagger v2 does not populate types
builder.type(Set.of(schemaType));
builder.type(schemaType == null ? Set.of() : Set.of(schemaType));
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,21 @@ void mapType() {
assertThat(componentSchema.getSchema().getType()).containsExactly(schema.getType());
}

@Test
void mapNullTypeForComposedSchema() {
// given
Schema<?> schema = new Schema<>();
// no type set - simulates a composed schema (allOf/oneOf/anyOf) with null type
schema.addAllOfItem(new Schema<>());

// when
ComponentSchema componentSchema = swaggerSchemaMapper.mapSchema(schema);

// then - should not throw NPE, type should be empty
assertThat(componentSchema.getSchema()).isNotNull();
assertThat(componentSchema.getSchema().getType()).isNullOrEmpty();
}

@Test
void mapProperties() {
// given
Expand Down Expand Up @@ -639,6 +654,7 @@ void mapMaxItems() {

@Nested
class MapToSwagger {

@Test
void mapNameAndTitle() {
// given
Expand Down
Loading