Skip to content
This repository has been archived by the owner on Jun 30, 2023. It is now read-only.

Commit

Permalink
fix schema generation for transformer corner case
Browse files Browse the repository at this point in the history
When a Transformer affects an array element type, SchemaRepository
treated it as the non-transformed type. If the Transformer transformed
to a primitive, SchemaRepository tried to add the primitive as an object
schema, resulting in an error. This fixes that by getting the schema
type when dealing with array types.
  • Loading branch information
tangiel committed Apr 21, 2017
1 parent e2dfc9b commit e29072d
Show file tree
Hide file tree
Showing 7 changed files with 359 additions and 243 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,8 +211,11 @@ private void fillInFieldInformation(Field.Builder builder, TypeToken<?> fieldTyp
builder.setSchemaReference(SchemaReference.create(this, config, fieldType));
} else if (ft == FieldType.ARRAY) {
Field.Builder arrayItemBuilder = Field.builder().setName(ARRAY_UNUSED_MSG);
fillInFieldInformation(arrayItemBuilder, Types.getArrayItemType(fieldType),
typesForConfig, config);
fillInFieldInformation(
arrayItemBuilder,
ApiAnnotationIntrospector.getSchemaType(Types.getArrayItemType(fieldType), config),
typesForConfig,
config);
builder.setArrayItemSchema(arrayItemBuilder.build());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,6 @@ public void testDirectoryIsCloneable() throws Exception {

private RestDescription getDiscovery(DiscoveryContext context, Class<?> serviceClass)
throws Exception {
ImmutableList.Builder<ApiConfig> builder = ImmutableList.builder();
ApiConfig config = configLoader.loadConfiguration(ServiceContext.create(), serviceClass);
// If the clone call fails, the generated discovery is invalid.
return Iterables.getFirst(
Expand Down
Loading

0 comments on commit e29072d

Please sign in to comment.