use of com.google.api.server.spi.config.ResourceSchema in project endpoints-java by cloudendpoints.
the class ResourceSchemaProviderTest method testMissingPropertyType.
@Test
public void testMissingPropertyType() {
ResourceSchema schema = getResourceSchema(MissingPropertyTypeBean.class);
assertThat(schema.getProperties().keySet()).containsExactly("bar");
}
use of com.google.api.server.spi.config.ResourceSchema in project endpoints-java by cloudendpoints.
the class ResourceSchemaProviderTest method testIgnoredPropertyNotReturned.
@Test
public void testIgnoredPropertyNotReturned() {
ResourceSchema schema = getResourceSchema(IgnoredPropertyBean.class);
assertThat(schema.getProperties().keySet()).containsExactly("foo");
}
use of com.google.api.server.spi.config.ResourceSchema in project endpoints-java by cloudendpoints.
the class ResourceSchemaProviderTest method testGenericJsonEntity.
@Test
public void testGenericJsonEntity() throws Exception {
ResourceSchema schema = getResourceSchema(GenericJsonEntity.class);
assertThat(schema.getProperties().keySet()).containsExactly("foo");
assertThat(schema.getProperties().get("foo").getJavaType()).isEqualTo(String.class);
}
use of com.google.api.server.spi.config.ResourceSchema in project endpoints-java by cloudendpoints.
the class SchemaRepository method createBeanSchema.
private Schema createBeanSchema(TypeToken<?> type, Map<TypeToken<?>, Schema> typesForConfig, ApiConfig config) {
Schema.Builder builder = Schema.builder().setName(Types.getSimpleName(type, config.getSerializationConfig())).setType("object");
ResourceSchema schema = resourceSchemaProvider.getResourceSchema(type, config);
for (Entry<String, ResourcePropertySchema> entry : schema.getProperties().entrySet()) {
String propertyName = entry.getKey();
ResourcePropertySchema propertySchema = entry.getValue();
TypeToken<?> propertyType = propertySchema.getType();
if (propertyType != null) {
Field.Builder fieldBuilder = Field.builder().setName(propertyName);
fillInFieldInformation(fieldBuilder, propertyType, propertySchema.getDescription(), typesForConfig, config);
builder.addField(propertyName, fieldBuilder.build());
}
}
return builder.build();
}
use of com.google.api.server.spi.config.ResourceSchema in project endpoints-java by cloudendpoints.
the class ResourceSchemaProviderTest method testDescribedProperty.
@Test
public void testDescribedProperty() {
ResourceSchema schema = getResourceSchema(DescribedPropertyBean.class);
assertEquals("description of foo", schema.getProperties().get("foo").getDescription());
assertEquals("description of bar", schema.getProperties().get("bar").getDescription());
assertEquals("description of choice", schema.getProperties().get("choice").getDescription());
}
Aggregations