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

Commit e29072d

Browse files
committed
fix schema generation for transformer corner case
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.
1 parent e2dfc9b commit e29072d

File tree

7 files changed

+359
-243
lines changed

7 files changed

+359
-243
lines changed

endpoints-framework/src/main/java/com/google/api/server/spi/config/model/SchemaRepository.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,8 +211,11 @@ private void fillInFieldInformation(Field.Builder builder, TypeToken<?> fieldTyp
211211
builder.setSchemaReference(SchemaReference.create(this, config, fieldType));
212212
} else if (ft == FieldType.ARRAY) {
213213
Field.Builder arrayItemBuilder = Field.builder().setName(ARRAY_UNUSED_MSG);
214-
fillInFieldInformation(arrayItemBuilder, Types.getArrayItemType(fieldType),
215-
typesForConfig, config);
214+
fillInFieldInformation(
215+
arrayItemBuilder,
216+
ApiAnnotationIntrospector.getSchemaType(Types.getArrayItemType(fieldType), config),
217+
typesForConfig,
218+
config);
216219
builder.setArrayItemSchema(arrayItemBuilder.build());
217220
}
218221
}

endpoints-framework/src/test/java/com/google/api/server/spi/discovery/DiscoveryGeneratorTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ public void testDirectoryIsCloneable() throws Exception {
183183

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

0 commit comments

Comments
 (0)