protected MType readParameterType(String name, JsonObject p, SwaggerExtension ex) { JsonObject schema = p.getObject(SCHEMA); if(null != schema) { return readType(schema, ex); }else{ return readType(name, p, ex); } }
private void addFlatList(String key, JsonObject json, List<KV> flat){ json.forEachProperty((s,o) ->{ if(null == o){ flat.add(new KV(key+"."+s,null)); return; } if(Beans.isSimpleProperty(o.getClass())){ flat.add(new KV(key+"."+s,o)); return; } if(o.getClass().isArray()){ Object[] arrays = (Object[])o; for (int i = 0; i < arrays.length; i ++){ addFlatList(key+"." + s + "["+i+"]",json.getObject(s),flat); } return; } if(o instanceof List){ List arrays = (List) o; for (int i = 0; i < arrays.size(); i ++){ addFlatList(key+"." + s + "["+i+"]",json.getObject(s),flat); } return; } addFlatList(key+"."+s,json.getObject(s),flat); }); } }
JsonObject definitions = swagger.getObject(DEFINITIONS); for(String key : definitions.keys()) { JsonObject definition = definitions.getObject(key); JsonObject props = definition.getObject(PROPERTIES); List<String> names = required.asList(); for(String name : names) { JsonObject prop = props.getObject(name); prop.asMap().put(REQUIRED, true); JsonObject securities = swagger.getObject(SECURITY_DEFINITIONS); if(null != securities) { for(String key : securities.keys()) { JsonObject security = securities.getObject(key); JsonObject scopes = security.getObject(SCOPES); if(null != scopes) { permissions.putAll(scopes.asMap());
protected MType readObjectType(String name, JsonObject o) { JsonObject additionalProperties = o.getObject(ADDITIONAL_PROPERTIES); if(null == additionalProperties) { //check is nested model Object property = o.get(PROPERTIES); if(null != property && property instanceof Map) { if(null == name) { name = "Embedded"; } MApiModelBuilder model = readModel(name, o.asMap()); return model.toMComplexType().build(); }else { return MObjectType.TYPE; } }else{ if(additionalProperties.asMap().isEmpty()) { return MObjectType.TYPE; }else { MType valueType = readType(additionalProperties); return new MDictionaryType(MSimpleTypes.STRING, valueType); } } }
public MApiResponseBuilder readResponse(String name, Map<String,Object> map) { MApiResponseBuilder mr = new MApiResponseBuilder(); JsonObject resp = JsonObject.of(map); mr.setName(name); mr.setSummary(resp.getString(SUMMARY)); mr.setDescription(resp.getString(DESCRIPTION)); try{ mr.setStatus(Integer.parseInt(name)); }catch(NumberFormatException e) { //not a http status. } JsonObject schema = resp.getObject(SCHEMA); if(null != schema) { mr.setType(readType(schema)); } return mr; }
protected MType readType(String name, JsonObject property, SwaggerExtension ex) { String ref = property.getString(REF); if(!Strings.isEmpty(ref)) { return readRefType(ref); } String type = property.getString(TYPE); if(Strings.isEmpty(type)) { if(!validate) { return null; } throw new InvalidSpecException("Invalid type in property : " + JSON.stringify(property.raw())); } MType mtype = null != ex ? ex.readType(type) : null; if(null != mtype) { return mtype; } if(type.equals(OBJECT)) { return readObjectType(name, property); } if(type.equals(ARRAY)) { return readCollectionType(property.getObject(ITEMS), ex); } String format = property.getString(FORMAT); return readSimpleType(type, format); }
JsonObject foreignTable = o.getObject("foreignTable"); if(null != foreignTable){ DbSchemaObjectNameBuilder nb = new DbSchemaObjectNameBuilder();