Search in sources :

Example 1 with Field

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;
}
Also used : Field(com.google.api.server.spi.config.model.Schema.Field) JsonSchema(com.google.api.services.discovery.model.JsonSchema)

Example 2 with Field

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;
}
Also used : Field(com.google.api.server.spi.config.model.Schema.Field) ModelImpl(io.swagger.models.ModelImpl) StringProperty(io.swagger.models.properties.StringProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) LongProperty(io.swagger.models.properties.LongProperty) Property(io.swagger.models.properties.Property) DoubleProperty(io.swagger.models.properties.DoubleProperty) DateTimeProperty(io.swagger.models.properties.DateTimeProperty) ByteArrayProperty(io.swagger.models.properties.ByteArrayProperty) RefProperty(io.swagger.models.properties.RefProperty) FloatProperty(io.swagger.models.properties.FloatProperty) DateProperty(io.swagger.models.properties.DateProperty) IntegerProperty(io.swagger.models.properties.IntegerProperty) BooleanProperty(io.swagger.models.properties.BooleanProperty)

Aggregations

Field (com.google.api.server.spi.config.model.Schema.Field)2 JsonSchema (com.google.api.services.discovery.model.JsonSchema)1 ModelImpl (io.swagger.models.ModelImpl)1 ArrayProperty (io.swagger.models.properties.ArrayProperty)1 BooleanProperty (io.swagger.models.properties.BooleanProperty)1 ByteArrayProperty (io.swagger.models.properties.ByteArrayProperty)1 DateProperty (io.swagger.models.properties.DateProperty)1 DateTimeProperty (io.swagger.models.properties.DateTimeProperty)1 DoubleProperty (io.swagger.models.properties.DoubleProperty)1 FloatProperty (io.swagger.models.properties.FloatProperty)1 IntegerProperty (io.swagger.models.properties.IntegerProperty)1 LongProperty (io.swagger.models.properties.LongProperty)1 Property (io.swagger.models.properties.Property)1 RefProperty (io.swagger.models.properties.RefProperty)1 StringProperty (io.swagger.models.properties.StringProperty)1