Java Code Examples for io.swagger.v3.oas.models.media.Schema#description()

The following examples show how to use io.swagger.v3.oas.models.media.Schema#description() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RefHelper.java    From raptor with Apache License 2.0 6 votes vote down vote up
private Map<String, Schema> buildProperties(MessageType protoType) {
    Map<String, Schema> properties = new LinkedHashMap<>();
    // 不处理oneof
    ImmutableList<Field> fields = protoType.fields();
    for (Field field : fields) {
        ProtoType fieldType = field.type();
        String fieldName = field.name();


        Schema property = getSchemaByType(fieldType);
        if (field.isRepeated()) {
            property = new ArraySchema().items(property);
        }
        property.description(field.documentation());
        properties.put(fieldName, property);
    }
    return properties;
}
 
Example 2
Source File: RefHelper.java    From raptor with Apache License 2.0 5 votes vote down vote up
private Schema buildSchema(ProtoType protoType) {
    Schema schema = new Schema();
    Type type = this.schema.getType(protoType);
    if (type instanceof EnumType) {
        schema.type("integer");
        // TODO: 2018/5/22 追加特别的描述
        schema.description(getDescriptionFromEnumType((EnumType) type));
        schema.setEnum(((EnumType) type).constants().stream().map(EnumConstant::tag).collect(Collectors.toList()));
    } else if (type instanceof MessageType) {
        schema.properties(buildProperties((MessageType) type));
    }
    return schema;
}