예제 #1
0
 public void addRequired(String name) {
   if (required == null) {
     required = new ArrayList<String>();
   }
   required.add(name);
   Property p = properties.get(name);
   if (p != null) {
     p.setRequired(true);
   }
 }
예제 #2
0
 public void setRequired(List<String> required) {
   this.required = required;
   if (properties != null) {
     for (String s : required) {
       Property p = properties.get(s);
       if (p != null) {
         p.setRequired(true);
       }
     }
   }
 }
 @Override
 public boolean isPropertyAllowed(
     Model model,
     Property property,
     String propertyName,
     Map<String, List<String>> params,
     Map<String, String> cookies,
     Map<String, List<String>> headers) {
   if (property.getVendorExtensions() != null
       && property.getVendorExtensions().containsKey(HIDDEN)) {
     return false;
   }
   return true;
 }
 @Override
 public String toDefaultValue(Property p) {
   if (!p.getRequired()) {
     return "None";
   }
   if (p instanceof StringProperty) {
     return "null";
   } else if (p instanceof BooleanProperty) {
     return "null";
   } else if (p instanceof DateProperty) {
     return "null";
   } else if (p instanceof DateTimeProperty) {
     return "null";
   } else if (p instanceof DoubleProperty) {
     return "null";
   } else if (p instanceof FloatProperty) {
     return "null";
   } else if (p instanceof IntegerProperty) {
     return "null";
   } else if (p instanceof LongProperty) {
     return "null";
   } else if (p instanceof MapProperty) {
     MapProperty ap = (MapProperty) p;
     String inner = getSwaggerType(ap.getAdditionalProperties());
     return "Map[String, " + inner + "].empty ";
   } else if (p instanceof ArrayProperty) {
     ArrayProperty ap = (ArrayProperty) p;
     String inner = getSwaggerType(ap.getItems());
     return "Seq[" + inner + "].empty ";
   } else {
     return "null";
   }
 }
예제 #5
0
 public List<String> getRequired() {
   List<String> output = new ArrayList<String>();
   if (properties != null) {
     for (String key : properties.keySet()) {
       Property prop = properties.get(key);
       if (prop != null && prop.getRequired()) {
         output.add(key);
       }
     }
   }
   Collections.sort(output);
   if (output.size() > 0) {
     return output;
   } else {
     return null;
   }
 }
예제 #6
0
 public void addProperty(String key, Property property) {
   if (property == null) {
     return;
   }
   if (properties == null) {
     properties = new LinkedHashMap<String, Property>();
   }
   if (required != null) {
     for (String ek : required) {
       if (key.equals(ek)) {
         property.setRequired(true);
       }
     }
   }
   properties.put(key, property);
 }
예제 #7
0
 @Override
 public int hashCode() {
   final int prime = 31;
   int result = super.hashCode();
   result =
       prime * result + ((additionalProperties == null) ? 0 : additionalProperties.hashCode());
   result = prime * result + ((description == null) ? 0 : description.hashCode());
   result = prime * result + ((discriminator == null) ? 0 : discriminator.hashCode());
   result = prime * result + ((example == null) ? 0 : example.hashCode());
   result = prime * result + ((format == null) ? 0 : format.hashCode());
   result = prime * result + (isSimple ? 1231 : 1237);
   result = prime * result + ((name == null) ? 0 : name.hashCode());
   result = prime * result + ((properties == null) ? 0 : properties.hashCode());
   result = prime * result + ((required == null) ? 0 : required.hashCode());
   result = prime * result + ((type == null) ? 0 : type.hashCode());
   result = prime * result + ((xml == null) ? 0 : xml.hashCode());
   result = prime * result + ((defaultValue == null) ? 0 : defaultValue.hashCode());
   return result;
 }
예제 #8
0
 @Override
 public boolean equals(Object obj) {
   if (this == obj) {
     return true;
   }
   if (!super.equals(obj)) {
     return false;
   }
   if (getClass() != obj.getClass()) {
     return false;
   }
   ModelImpl other = (ModelImpl) obj;
   if (additionalProperties == null) {
     if (other.additionalProperties != null) {
       return false;
     }
   } else if (!additionalProperties.equals(other.additionalProperties)) {
     return false;
   }
   if (description == null) {
     if (other.description != null) {
       return false;
     }
   } else if (!description.equals(other.description)) {
     return false;
   }
   if (discriminator == null) {
     if (other.discriminator != null) {
       return false;
     }
   } else if (!discriminator.equals(other.discriminator)) {
     return false;
   }
   if (example == null) {
     if (other.example != null) {
       return false;
     }
   } else if (!example.equals(other.example)) {
     return false;
   }
   if (format == null) {
     if (other.format != null) {
       return false;
     }
   } else if (!format.equals(other.format)) {
     return false;
   }
   if (isSimple != other.isSimple) {
     return false;
   }
   if (name == null) {
     if (other.name != null) {
       return false;
     }
   } else if (!name.equals(other.name)) {
     return false;
   }
   if (properties == null) {
     if (other.properties != null) {
       return false;
     }
   } else if (!properties.equals(other.properties)) {
     return false;
   }
   if (required == null) {
     if (other.required != null) {
       return false;
     }
   } else if (!required.equals(other.required)) {
     return false;
   }
   if (type == null) {
     if (other.type != null) {
       return false;
     }
   } else if (!type.equals(other.type)) {
     return false;
   }
   if (xml == null) {
     if (other.xml != null) {
       return false;
     }
   } else if (!xml.equals(other.xml)) {
     return false;
   }
   if (defaultValue == null) {
     if (other.defaultValue != null) {
       return false;
     }
   } else if (!defaultValue.equals(other.defaultValue)) {
     return false;
   }
   return true;
 }
예제 #9
0
 public void addRequired(String name) {
   Property p = properties.get(name);
   if (p != null) {
     p.setRequired(true);
   }
 }