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

The following examples show how to use io.swagger.v3.oas.models.media.Schema#getNot() . 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: SchemaProcessor.java    From swagger-parser with Apache License 2.0 6 votes vote down vote up
public void processSchemaType(Schema schema){

        if (schema instanceof ArraySchema) {
            processArraySchema((ArraySchema) schema);
        }
        if (schema instanceof ComposedSchema) {
            processComposedSchema((ComposedSchema) schema);
        }

        if(schema.getProperties() != null && schema.getProperties().size() > 0){
            processPropertySchema(schema);
        }

        if(schema.getNot() != null){
            processNotSchema(schema);
        }
        if(schema.getAdditionalProperties() != null){
            processAdditionalProperties(schema);
            
        }
        if (schema.getDiscriminator() != null) {
            processDiscriminatorSchema(schema);
        }

    }
 
Example 2
Source File: BodyGenerator.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
public String generate(Schema<?> schema) {
    if (schema == null) {
        return "";
    }

    boolean isArray = schema instanceof ArraySchema;
    if (LOG.isDebugEnabled()) {
        LOG.debug("Generate body for object " + schema.getName());
    }

    if (isArray) {
        return generateFromArraySchema((ArraySchema) schema);
    }

    @SuppressWarnings("rawtypes")
    Map<String, Schema> properties = schema.getProperties();
    if (properties != null) {
        return generateFromObjectSchema(properties);
    } else if (schema.getAdditionalProperties() instanceof Schema) {
        return generate((Schema<?>) schema.getAdditionalProperties());
    }

    if (schema instanceof ComposedSchema) {
        return generateJsonPrimitiveValue(resolveComposedSchema((ComposedSchema) schema));
    }
    if (schema.getNot() != null) {
        resolveNotSchema(schema);
    }

    // primitive type, or schema without properties
    if (schema.getType() == null || schema.getType().equals("object")) {
        schema.setType("string");
    }

    return generateJsonPrimitiveValue(schema);
}
 
Example 3
Source File: SchemaProcessor.java    From swagger-parser with Apache License 2.0 5 votes vote down vote up
private void processNotSchema(Schema schema) {

        if (schema.getNot() != null){
            if(schema.getNot().get$ref() != null){
                processReferenceSchema(schema.getNot());
            }else{
                processSchemaType(schema.getNot());
            }
        }
    }
 
Example 4
Source File: SchemaUtils.java    From tcases with MIT License 4 votes vote down vote up
/**
 * Returns true if this is a basic schema without any boolean combinations of subschemas.
 */
public static boolean isLeafSchema( Schema<?> schema)
  {
  return asComposedSchema( schema) == null && schema.getNot() == null;
  }