Java Code Examples for io.swagger.v3.oas.models.media.ComposedSchema#setType()

The following examples show how to use io.swagger.v3.oas.models.media.ComposedSchema#setType() . 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: SchemaGeneratorHelper.java    From spring-openapi with MIT License 5 votes vote down vote up
protected ComposedSchema createRefSchema(Class<?> typeSignature, List<String> modelPackages) {
    ComposedSchema composedSchema = new ComposedSchema();

    if (modelPackages == null || isInPackagesToBeScanned(typeSignature, modelPackages)) {
        composedSchema.set$ref(COMPONENT_REF_PREFIX + typeSignature.getSimpleName());
        return composedSchema;

    }

    // fallback
    composedSchema.setType("object");
    return composedSchema;
}
 
Example 2
Source File: SchemaBuilder.java    From tcases with MIT License 5 votes vote down vote up
/**
 * Creates a new builder for a ComposedSchema with the given type.
 */
public static SchemaBuilder composed( String type)
  {
  ComposedSchema schema = new ComposedSchema();
  schema.setType( type);
  return new SchemaBuilder( schema);
  }
 
Example 3
Source File: InlineModelResolver.java    From swagger-parser with Apache License 2.0 4 votes vote down vote up
public Schema createModelFromProperty(Schema schema, String path) {
    String description = schema.getDescription();
    String example = null;
    List<String> requiredList = schema.getRequired();


    Object obj = schema.getExample();
    if (obj != null) {
        example = obj.toString();
    }
    String name = schema.getName();
    XML xml = schema.getXml();
    Map<String, Schema> properties = schema.getProperties();


    if (schema instanceof ComposedSchema && this.flattenComposedSchemas){
        ComposedSchema composedModel = (ComposedSchema) schema;

        composedModel.setDescription(description);
        composedModel.setExample(example);
        composedModel.setName(name);
        composedModel.setXml(xml);
        composedModel.setType(schema.getType());
        composedModel.setRequired(requiredList);

        return composedModel;


    } else {
        Schema model = new Schema();//TODO Verify this!
        model.setDescription(description);
        model.setExample(example);
        model.setName(name);
        model.setXml(xml);
        model.setType(schema.getType());
        model.setRequired(requiredList);

        if (properties != null) {
            flattenProperties(properties, path);
            model.setProperties(properties);
        }

        return model;
    }
}