List<String> tags = tags(op); Map operation = op.asMap(); operation.put(ID, "op" + index++); operation.put(METHOD, method.toUpperCase());
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 MetaModel read(Resource file) { String content = file.getContent().trim(); if (content.length() == 0) { return null; } String name = Strings.upperFirst(Paths.getFileNameWithoutExtension(file.getFilename())); JsonObject o = JSON.parse(file.getContent()).asJsonObject(); if(o.asMap().isEmpty()) { return null; } MetaModel model = JSON.convert(o.asMap(), MetaModel.class); if (!Strings.isEmpty(model.getClassName())) { Class<?> c = Classes.tryForName(model.getClassName()); if (null == c) { throw new IllegalStateException("Model class '" + model.getClassName() + "' not found!"); } MType type = MTypes.getMType(c); if (!type.isComplexType()) { throw new IllegalStateException("The model class '" + model.getClassName() + "' must be complex type!"); } MetaUtils.tryCopyModel(type.asComplexType(), model); } MApiModelBuilder am = nonValidateSwaggerReader.readModel(name, o.asMap(), new SwaggerTypeEx()); MetaUtils.tryCopyModel(am, model); validator.validate("Model(" + model.getName() + ")", model); return model; }
protected UserPrincipal newUserInfo(JsonObject json) { SimpleUserPrincipal userInfo = new SimpleUserPrincipal(); userInfo.setId(json.getString("sub")); userInfo.setName(json.getString("name")); userInfo.setLoginName(json.getString("login_name")); userInfo.setProperties(json.asMap()); return userInfo; }