use of com.google.api.server.spi.config.model.Schema.Field in project endpoints-java by cloudendpoints.
the class DiscoveryGenerator method convertToDiscoverySchema.
private JsonSchema convertToDiscoverySchema(Schema schema) {
JsonSchema docSchema = new JsonSchema().setId(schema.name()).setType(schema.type());
if (!schema.fields().isEmpty()) {
Map<String, JsonSchema> fields = Maps.newLinkedHashMap();
for (Field f : schema.fields().values()) {
fields.put(f.name(), convertToDiscoverySchema(f));
}
docSchema.setProperties(fields);
}
docSchema.setDescription(schema.description());
if (!schema.enumValues().isEmpty()) {
docSchema.setEnum(new ArrayList<>(schema.enumValues()));
docSchema.setEnumDescriptions(new ArrayList<>(schema.enumDescriptions()));
}
return docSchema;
}
use of com.google.api.server.spi.config.model.Schema.Field in project endpoints-java by cloudendpoints.
the class SwaggerGenerator method convertToSwaggerSchema.
private Model convertToSwaggerSchema(Schema schema) {
ModelImpl docSchema = new ModelImpl();
Map<String, Property> fields = Maps.newLinkedHashMap();
if (!schema.fields().isEmpty()) {
for (Field f : schema.fields().values()) {
fields.put(f.name(), convertToSwaggerProperty(f));
}
docSchema.setProperties(fields);
}
if (!schema.enumValues().isEmpty()) {
docSchema._enum(schema.enumValues());
}
return docSchema;
}
Aggregations