• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java RamlModelResult类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.raml.v2.api.RamlModelResult的典型用法代码示例。如果您正苦于以下问题:Java RamlModelResult类的具体用法?Java RamlModelResult怎么用?Java RamlModelResult使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RamlModelResult类属于org.raml.v2.api包,在下文中一共展示了RamlModelResult类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: main

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public static void main(String[] args) throws Exception  {

        RamlModelResult ramlModelResult =
                new RamlModelBuilder().buildApi(
                        new FileReader("/Users/jpbelang/IdeaProjects/raml-java-tools/raml-to-pojo/src/test/resources/org/raml/ramltopojo/union/union-primitive-type.raml"),
                        ".");
        if (ramlModelResult.hasErrors()) {
            for (ValidationResult validationResult : ramlModelResult.getValidationResults()) {
                System.err.println(validationResult.getMessage());
            }
            throw new Exception();
        }

        final Api api = ramlModelResult.getApiV10();
        RamlToPojo ramlToPojo = RamlToPojoBuilder.builder(api)
                .inPackage("my.packaging")
                .fetchTypes(fromAnywhere())
                .findTypes(everyWhere()).build();

        ramlToPojo.buildPojos().createAllTypes("/Users/jpbelang/IdeaProjects/raml-java-tools/garbage/src/main/java");
    }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:22,代码来源:Main.java


示例2: main

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
    // URL url = Main.class.getResource("api.raml");
    URL url = Main.class.getResource("fun.raml");

    Reader reader = new InputStreamReader(url.openStream());

    RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(reader, url.getFile());
    if (ramlModelResult.hasErrors()) {
        for (ValidationResult validationResult : ramlModelResult.getValidationResults()) {
            System.err.println(validationResult);
        }
    } else {

        Api realApi = ramlModelResult.getApiV10();
        System.err.println("grr " + realApi.annotationTypes().get(0).name());
    }
}
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:18,代码来源:OtherMain.java


示例3: main

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public static void main(String[] args) {

        RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(new File(Query.class.getResource("/api.raml").getFile()));
        if (ramlModelResult.hasErrors()) {
            for (ValidationResult validationResult : ramlModelResult.getValidationResults()) {
                System.out.println(validationResult.getMessage());
            }

        } else {
            Api api = ramlModelResult.getApiV10();

            List<Resource> tr = from(api).select(Selectors.allResources()).toList();
            for (Resource resource : tr) {
                System.err.println(resource.resourcePath());
            }
        }
    }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:18,代码来源:Query.java


示例4: test1

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public void test1(){
	ApiImpl model=new ApiImpl();
	model.setTitle("Hello");
	ActionImpl orCreateMethod = model.getOrCreateResource("persons").getOrCreateMethod("get");
	orCreateMethod.addBody("application/json", BuiltIns.OBJECT);
	AbstractType deriveObjectType = TypeOps.deriveObjectType("");
	deriveObjectType.declareProperty("name", BuiltIns.STRING,false);
	deriveObjectType.declareProperty("lastName", BuiltIns.STRING,false);
	deriveObjectType.declareProperty("age", BuiltIns.INTEGER,false);	
	orCreateMethod.addResponse("200","application/json", deriveObjectType);
	orCreateMethod.addQueryParameter(new NamedParamImpl("count",BuiltIns.STRING, true, true));
	orCreateMethod.addQueryParameter(new NamedParamImpl("offset",BuiltIns.STRING, false, true));
	String store = new RamlWriter().store(model);
	RamlModelResult buildApi = new RamlModelBuilder().buildApi(store, "");
	
	TestCase.assertTrue(!buildApi.hasErrors());
	Api api=(Api) new TopLevelRamlModelBuilder().build(store, new CompositeResourceLoader(),"");
	TestCase.assertTrue(api.resources().get(0).methods().get(0).queryParameters().get(0).isRequired());
	TestCase.assertTrue(!api.resources().get(0).methods().get(0).queryParameters().get(1).isRequired());
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:21,代码来源:WriterTest.java


示例5: test2

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public void test2(){
	ApiImpl model=new ApiImpl();
	model.setTitle("Hello");
	ActionImpl orCreateMethod = model.getOrCreateResource("persons").getOrCreateMethod("get");
	orCreateMethod.addBody("application/json", BuiltIns.OBJECT);
	AbstractType deriveObjectType = TypeOps.deriveObjectType("Person");
	deriveObjectType.declareProperty("name", BuiltIns.STRING,false);
	deriveObjectType.declareProperty("lastName", BuiltIns.STRING,false);
	deriveObjectType.declareProperty("age", BuiltIns.INTEGER,false);	
	orCreateMethod.addResponse("200","application/json", deriveObjectType);
	model.addType(deriveObjectType);
	orCreateMethod.addQueryParameter(new NamedParamImpl("count",BuiltIns.STRING, true, true));
	orCreateMethod.addQueryParameter(new NamedParamImpl("offset",BuiltIns.STRING, false, true));
	String store = new RamlWriter().store(model);
	RamlModelResult buildApi = new RamlModelBuilder().buildApi(store, "");
	
	TestCase.assertTrue(!buildApi.hasErrors());
	Api api=(Api) new TopLevelRamlModelBuilder().build(store, new CompositeResourceLoader(),"");
	TestCase.assertTrue(api.resources().get(0).methods().get(0).queryParameters().get(0).isRequired());
	TestCase.assertTrue(!api.resources().get(0).methods().get(0).queryParameters().get(1).isRequired());
	TestCase.assertTrue(api.resources().get(0).methods().get(0).responses().get(0).body().get(0).getTypeModel().name().equals("Person"));
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:23,代码来源:WriterTest.java


示例6: test3

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public void test3(){
	ApiImpl model=new ApiImpl();
	model.setTitle("Hello");
	ActionImpl orCreateMethod = model.getOrCreateResource("persons").getOrCreateMethod("get");
	orCreateMethod.addBody("application/json", BuiltIns.OBJECT);
	AbstractType deriveObjectType = TypeOps.deriveObjectType("Person");
	deriveObjectType.declareProperty("name", BuiltIns.STRING,false);
	deriveObjectType.declareProperty("lastName", BuiltIns.STRING,false);
	deriveObjectType.declareProperty("age", BuiltIns.INTEGER,false);	
	orCreateMethod.addResponse("200","application/json", deriveObjectType);
	model.addType(deriveObjectType);
	orCreateMethod.addQueryParameter(new NamedParamImpl("count",BuiltIns.STRING, true, true));
	orCreateMethod.addQueryParameter(new NamedParamImpl("offset",BuiltIns.STRING, false, true));
	String store = new RamlWriter().store(model);
	RamlModelResult buildApi = new RamlModelBuilder().buildApi(store, "");		
	TestCase.assertTrue(!buildApi.hasErrors());
	Api api=(Api) new TopLevelRamlModelBuilder().build(store, new CompositeResourceLoader(),"");
	TestCase.assertTrue(api.resources().get(0).methods().get(0).queryParameters().get(0).isRequired());
	TestCase.assertTrue(!api.resources().get(0).methods().get(0).queryParameters().get(1).isRequired());
	TestCase.assertTrue(api.resources().get(0).methods().get(0).responses().get(0).body().get(0).getTypeModel().name().equals("Person"));
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:22,代码来源:WriterTest.java


示例7: test6

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void test6(){
	ApiImpl model=new ApiImpl();
	model.setTitle("hello");
	SecuritySchemeImpl e = new SecuritySchemeImpl();
	e.setName("o2");
	e.settings().put("accessTokenUri","http");
	e.settings().put("authorizationUri","http");
	e.settings().put("authorizationGrants","password");
	e.setType("OAuth 2.0");
	e.settings().put("scopes", new String[]{"a","b"});
	model.securityDefinitions().add(e);
	String store = new RamlWriter().store(model);		
	RamlModelResult buildApi = new RamlModelBuilder().buildApi(store, "");	
	TestCase.assertTrue(!buildApi.hasErrors());		
	Api api=(Api) new TopLevelRamlModelBuilder().build(store, new CompositeResourceLoader(),"");
	TestCase.assertTrue(Arrays.equals((Object[])((List<Object>) api.securityDefinitions().get(0).settings().get("scopes")).toArray(), new Object[]{"a","b"}));
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:19,代码来源:WriterTest.java


示例8: test7

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public void test7(){
	ApiImpl model=new ApiImpl();
	ActionImpl orCreateMethod = model.getOrCreateResource("persons").getOrCreateMethod("get");
	model.setTitle("hello");
	SecuritySchemeImpl e = new SecuritySchemeImpl();
	e.setName("oauth2");
	e.settings().put("accessTokenUri","http");
	e.settings().put("authorizationUri","http");
	e.settings().put("authorizationGrants","password");
	e.setType("OAuth 2.0");
	e.settings().put("scopes", new String[]{"a","b"});
	orCreateMethod.securedBy().add(new SecuredByConfigImpl("oauth2").with("scopes",new String[]{"c"}));
	model.securityDefinitions().add(e);
	String store = new RamlWriter().store(model);		
	RamlModelResult buildApi = new RamlModelBuilder().buildApi(store, "");	
	TestCase.assertTrue(!buildApi.hasErrors());		
	Api api=(Api) new TopLevelRamlModelBuilder().build(store, new CompositeResourceLoader(),"");
	Object os=api.resources().get(0).methods().get(0).securedBy().get(0).settings().get("scopes");
	TestCase.assertEquals(os.toString(), "[c]");
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:21,代码来源:WriterTest.java


示例9: init

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
private void init(String ramlLocation) {
    try {
        RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(ramlLocation);

        Preconditions.checkArgument(!ramlModelResult.hasErrors(),
                ramlModelResult.getValidationResults()
                        .stream()
                        .map(ValidationResult::getMessage)
                        .collect(Collectors.joining(", "))
        );

        Api api = ramlModelResult.getApiV08();

        Preconditions.checkArgument(api != null, "API cannot be null. Check if there were errors or the RAML version is not 0.8");

        logger.debug("RAML title: {}, version: {}", api.title(), api.version());

        api.resources().forEach(this::addStubIfHaveExamples);

    } catch(Exception ex) {
        logger.error("Error {} while loading raml. Shutting down server. ", ex.getMessage());
        this.shutdownServer();
        throw new IllegalStateException(ex);
    }
}
 
开发者ID:arielsegura,项目名称:raml-java-mock-server,代码行数:26,代码来源:RamlMockServer.java


示例10: createRamlModelFactoryFor

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
/**
 * 
 * Creates a Model factory for a specific raml document based on the documents version
 * if the ramlVersion is specified, the model factory will only be created if the document is compatible with this specified version
 * 
 * @param ramlURL The raml file for which to create a factory
 * @param ramlVersion (nullable) The Version of raml for which to create a factory
 * @return The Factory instance for this RAML document
 */
public static RamlModelFactory createRamlModelFactoryFor(String ramlURL, RamlVersion ramlVersion) {
	RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(ramlURL);
	if (ramlModelResult.hasErrors()) {
		logger.error("Loaded RAML has validation errors: "+ StringUtils.collectionToCommaDelimitedString(ramlModelResult.getValidationResults()));
	}
    if (ramlModelResult.isVersion10() 
    		&& (ramlVersion == null || RamlVersion.V10.equals(ramlVersion))) {
    	logger.info("RJP10V2RamlModelFactory Instantiated");
    	return new RJP10V2RamlModelFactory();
    }
    if ((!ramlModelResult.hasErrors() && RamlVersion.V08.equals(ramlVersion)) //To keep legacy support try load using the 08 if requested specifically
    		|| (ramlModelResult.isVersion08() && (ramlVersion == null || RamlVersion.V08.equals(ramlVersion)))) {
    	logger.info("RJP08V1RamlModelFactory Instantiated");
    	return new RJP08V1RamlModelFactory();
    }

    if (containsUnsupportedVersionError(ramlModelResult.getValidationResults()) || !isSupportedRamlVersionCombination(ramlVersion, ramlModelResult)) {
        throw new UnsupportedRamlVersionError(RamlVersion.V08, RamlVersion.V10);
    }

    throw new InvalidRamlError(ramlURL, ramlModelResult.getValidationResults());
}
 
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:32,代码来源:RamlModelFactoryOfFactories.java


示例11: buildRamlRoot

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
@Override
public RamlRoot buildRamlRoot(String ramlFileUrl) throws InvalidRamlResourceException {
    RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(ramlFileUrl);
    if (ramlModelResult.hasErrors()) {
        List<String> errors = ramlModelResult.getValidationResults()
                .stream()
                .map(validationResult -> validationResult.getMessage())
                .collect(Collectors.toList());
        throw new InvalidRamlResourceException(ramlFileUrl, errors);
    }

    // The Api is created by RamlModelBuilder during runtime via a yagi ModelProxyBuilder.
    // In org.raml.v2 there is no direct implementation for Api interface during compile time.
    Api api = ramlModelResult.getApiV10();
    return new RJP10V2RamlRoot(api);
}
 
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:17,代码来源:RJP10V2RamlModelFactory.java


示例12: load

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public static Api load(InputStream is, String directory) {

        RamlModelResult ramlModelResult =
                new RamlModelBuilder().buildApi(
                        new InputStreamReader(is), directory);
        if (ramlModelResult.hasErrors()) {
            for (ValidationResult validationResult : ramlModelResult.getValidationResults()) {
                System.out.println(validationResult.getMessage());
            }
            throw new AssertionError();
        } else {
            return ramlModelResult.getApiV10();
        }
    }
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:15,代码来源:RamlLoader.java


示例13: execute

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
@Override
public void execute() throws MojoExecutionException, MojoFailureException {

    getLog().error("GAAAAAA!");
    if (skip) {
        getLog().info("Skipping execution...");
        return;
    }

    if (ramlFile == null) {
        throw new MojoExecutionException("ramlFile is not defined");
    }

    try {
        FileUtils.forceMkdir(outputDirectory);
    } catch (final IOException ioe) {
        throw new MojoExecutionException("Failed to create directory: " + outputDirectory, ioe);
    }

    try {
        project.addCompileSourceRoot(outputDirectory.getPath());

        RamlModelResult ramlModelResult =
                new RamlModelBuilder().buildApi(
                        new FileReader(ramlFile),
                        ".");
        if (ramlModelResult.hasErrors()) {
            for (ValidationResult validationResult : ramlModelResult.getValidationResults()) {
                System.err.println(validationResult.getMessage());
            }
            throw new MojoExecutionException("invalid raml " + ramlFile);
        }

        final Api api = ramlModelResult.getApiV10();
        RamlToPojo ramlToPojo = RamlToPojoBuilder.builder(api)
                .inPackage(defaultPackage)
                .fetchTypes(fromAnywhere())
                .findTypes(everyWhere()).build();

        ramlToPojo.buildPojos().createAllTypes(outputDirectory.getAbsolutePath());

    } catch (IOException e) {

        throw new MojoExecutionException("execution exception", e);
    }
}
 
开发者ID:mulesoft-labs,项目名称:raml-java-tools,代码行数:47,代码来源:RamlToPojoMojo.java


示例14: main

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public static void main(String[] args) {
    RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(Paths.get("build", "ramldoc", "api.raml").toFile());
    if (ramlModelResult.hasErrors()) {
        for (ValidationResult validationResult : ramlModelResult.getValidationResults())
        {
            System.out.println(validationResult.getMessage());
        }
    } else {
        System.out.println("validation successful");
        Api api = ramlModelResult.getApiV10();
    }
}
 
开发者ID:ePages-de,项目名称:restdocs-raml,代码行数:13,代码来源:RamlValidator.java


示例15: test

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public void test() {
	AbstractType deriveObjectType = TypeOps.deriveObjectType("Person");
	deriveObjectType.declareProperty("name", BuiltIns.STRING,false);
	deriveObjectType.declareProperty("lastName", BuiltIns.STRING,false);
	deriveObjectType.declareProperty("age", BuiltIns.INTEGER,false);		
	DumperOptions dumperOptions = new DumperOptions();
	dumperOptions.setDefaultFlowStyle(FlowStyle.BLOCK);		
	RamlWriter w=new RamlWriter();
	String result=w.store(deriveObjectType);
	RamlModelResult buildApi = new RamlModelBuilder().buildApi(result, "");
	TestCase.assertTrue(!buildApi.hasErrors());
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:13,代码来源:WriterTest.java


示例16: test4

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public void test4(){
	ApiImpl model=new ApiImpl();
	model.setTitle("Hello");
	model.addAnnotationType(TypeOps.derive("HelloAnnotation", BuiltIns.STRING));
	model.annotations().add(new Annotation("HelloAnnotation", "Hello"));
	String store = new RamlWriter().store(model);		
	RamlModelResult buildApi = new RamlModelBuilder().buildApi(store, "");		
	TestCase.assertTrue(!buildApi.hasErrors());		
	Api api=(Api) new TopLevelRamlModelBuilder().build(store, new CompositeResourceLoader(),"");
	AbstractType tp=api.annotations().get(0).annotationType();
	TestCase.assertTrue(tp.name().equals("HelloAnnotation"));
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:13,代码来源:WriterTest.java


示例17: test5

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
public void test5(){
	ApiImpl model=new ApiImpl();
	model.setTitle("Hello");
	model.addAnnotationType(TypeOps.derive("HelloAnnotation", BuiltIns.STRING));
	ActionImpl orCreateMethod = model.getOrCreateResource("persons").getOrCreateMethod("get");
	orCreateMethod.annotations().add(new Annotation("HelloAnnotation", "Hello"));
	String store = new RamlWriter().store(model);		
	RamlModelResult buildApi = new RamlModelBuilder().buildApi(store, "");		
	TestCase.assertTrue(!buildApi.hasErrors());		
	Api api=(Api) new TopLevelRamlModelBuilder().build(store, new CompositeResourceLoader(),"");
	TestCase.assertTrue(api.resources().get(0).methods().get(0).annotations().get(0).value().equals("Hello"));
}
 
开发者ID:OnPositive,项目名称:aml,代码行数:13,代码来源:WriterTest.java


示例18: buildApiModel

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
/**
 * Builds an API model for the given RAML source file.
 * @param sourceFileName source file name
 * @return API model
 * @throws ParserException on syntax errors
 */
public ApiModel buildApiModel(String sourceFileName) {
    RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi(sourceFileName);
    if (ramlModelResult.hasErrors()) {
        for (ValidationResult result : ramlModelResult.getValidationResults()) {
            log.error("{}: {}", result.getPath(), result.getMessage());
        }
        throw new ParserException("RAML syntax errors, see previous messages");
    }

    Api api = ramlModelResult.getApiV10();
    return new ApiModel(api);
}
 
开发者ID:ops4j,项目名称:org.ops4j.ramler,代码行数:19,代码来源:ApiModelBuilder.java


示例19: parse

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
private void parse(String simpleName) {
    RamlModelResult ramlModelResult = new RamlModelBuilder().buildApi("raml/" + simpleName);
    if (ramlModelResult.hasErrors()) {
        log.error("Parse errors: {}",ramlModelResult.getValidationResults());
    }
    assertThat(ramlModelResult.hasErrors()).isFalse();
    Api api = ramlModelResult.getApiV10();
    apiModel = new ApiModel(api);
}
 
开发者ID:ops4j,项目名称:org.ops4j.ramler,代码行数:10,代码来源:ParserTest.java


示例20: isSupportedRamlVersionCombination

import org.raml.v2.api.RamlModelResult; //导入依赖的package包/类
private static boolean isSupportedRamlVersionCombination(RamlVersion ramlVersion, RamlModelResult ramlModelResult) {
    if (ramlVersion != null) {
        if (RamlVersion.V08.equals(ramlVersion) && ramlModelResult.isVersion08()) {
            return true;
        }
        if (RamlVersion.V10.equals(ramlVersion) && ramlModelResult.isVersion10()) {
            return true;
        }
        return false;
    } else {
        return true; // add unsupported ramlModelResult.isVersionXX() here and return false
    }
}
 
开发者ID:phoenixnap,项目名称:springmvc-raml-plugin,代码行数:14,代码来源:RamlModelFactoryOfFactories.java



注:本文中的org.raml.v2.api.RamlModelResult类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java RpcUtil类代码示例发布时间:2022-05-22
下一篇:
Java ClassFilter类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap