List of usage examples for java.lang Package getAnnotation
public <A extends Annotation> A getAnnotation(Class<A> annotationClass)
From source file:com.cpjit.swagger4j.APIParser.java
/** * ?definition/*ww w. ja va2 s . com*/ * * @return definition * @throws Exception */ private Map<String, Object> parseDefinition() throws Exception { Map<String, Object> definitions = new HashMap<String, Object>(); for (Package pk : packages) { APISchemas apiSchemas = pk.getAnnotation(APISchemas.class); if (apiSchemas == null) { continue; } APISchema[] schemas = apiSchemas.schemas(); for (APISchema schema : schemas) { Map<String, Object> definition = new HashMap<String, Object>(); definition.put("type", schema.type()); List<String> required = new ArrayList<String>(); definition.put("required", required); APISchemaPropertie[] props = schema.properties(); Map<String, Map<String, Object>> properties = new HashMap<String, Map<String, Object>>(); for (APISchemaPropertie prop : props) { Map<String, Object> propertie = new HashMap<String, Object>(); definition.put("properties", properties); propertie.put("type", prop.type()); propertie.put("format", prop.format()); propertie.put("description", prop.description()); if (prop.required()) { // ? required.add(prop.value()); } if (prop.optionalValue().length > 0) { // ? propertie.put("enum", parseOptionalValue(prop.type(), prop.optionalValue())); } properties.put(prop.value(), propertie); } definitions.put(schema.value(), definition); // definition } } return definitions; }