当前位置: 首页>>代码示例>>Java>>正文


Java SwaggerParser类代码示例

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


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

示例1: shouldCreatePropertyParametersFromPetstoreSwagger

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
@Test
public void shouldCreatePropertyParametersFromPetstoreSwagger() throws IOException {
    final String specification = resource("/swagger/petstore.swagger.json");
    final Swagger swagger = new SwaggerParser().parse(specification);

    final Parameter petIdPathParameter = swagger.getPath("/pet/{petId}").getGet().getParameters().get(0);

    final Optional<ConfigurationProperty> maybeConfigurationProperty = BaseSwaggerConnectorGenerator
        .createPropertyFromParameter(petIdPathParameter);

    final ConfigurationProperty expected = new ConfigurationProperty.Builder()//
        .componentProperty(false)//
        .deprecated(false)//
        .description("ID of pet to return")//
        .displayName("petId")//
        .group("producer")//
        .javaType(Long.class.getName())//
        .kind("property")//
        .required(true)//
        .secret(false)//
        .type("integer")//
        .build();

    assertThat(maybeConfigurationProperty).hasValue(expected);
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:26,代码来源:BaseSwaggerConnectorGeneratorTest.java

示例2: swaggerDocProxy

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
@RequestMapping(value = "/swaggerDocProxy/{id}", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_UTF8_VALUE)
public Swagger swaggerDocProxy(@PathVariable(value = "id") Integer id,
                               @RequestParam(value = "trimSystemController", defaultValue = "true") boolean trimSystemController,
                               HttpServletRequest request) {
    Document document = documentService.findOne(id);
    if (document != null) {
        Swagger swagger = new SwaggerParser()
                .parse(document.getContent());
        if (trimSystemController) {
            swagger = Generator.convertSwagger(swagger);
        }
        swagger.setHost(request.getServerName() + ":" + request.getServerPort() + prefix + "/" + id);
        return swagger;
    }
    return null;
}
 
开发者ID:wu191287278,项目名称:sc-generator,代码行数:17,代码来源:DocumentController.java

示例3: start

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
    Json.mapper.registerModule(new JavaTimeModule());
	FileSystem vertxFileSystem = vertx.fileSystem();
    vertxFileSystem.readFile("swagger.json", readFile -> {
        if (readFile.succeeded()) {
            Swagger swagger = new SwaggerParser().parse(readFile.result().toString(Charset.forName("utf-8")));
            Router swaggerRouter = SwaggerRouter.swaggerRouter(Router.router(vertx), swagger, vertx.eventBus(), new OperationIdServiceIdResolver());
        
            deployVerticles(startFuture);
            
            vertx.createHttpServer() 
                .requestHandler(swaggerRouter::accept) 
                .listen(8080);
            startFuture.complete();
        } else {
        	startFuture.fail(readFile.cause());
        }
    });        		        
}
 
开发者ID:cliffano,项目名称:swaggy-jenkins,代码行数:21,代码来源:MainApiVerticle.java

示例4: testSwaggerJSON

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
@Test
public void testSwaggerJSON() {

    SutInfoDto dto = remoteController.getSutInfo();

    String swaggerJson = given().accept(Formats.JSON_V1)
            .get(dto.swaggerJsonUrl)
            .then()
            .statusCode(200)
            .extract().asString();

    Swagger swagger = new SwaggerParser().parse(swaggerJson);

    assertEquals("/", swagger.getBasePath());
    assertEquals(3, swagger.getPaths().size());
}
 
开发者ID:EMResearch,项目名称:EvoMaster,代码行数:17,代码来源:StringsManualTest.java

示例5: testSwaggerJSON

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
@Test
public void testSwaggerJSON() {

    SutInfoDto dto = remoteController.getSutInfo();

    String swaggerJson = given().accept(Formats.JSON_V1)
            .get(dto.swaggerJsonUrl)
            .then()
            .statusCode(200)
            .extract().asString();

    Swagger swagger = new SwaggerParser().parse(swaggerJson);

    assertEquals("/", swagger.getBasePath());
    assertEquals(2, swagger.getPaths().size());
}
 
开发者ID:EMResearch,项目名称:EvoMaster,代码行数:17,代码来源:PIManualTest.java

示例6: start

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
@Override
public void start(Future<Void> startFuture) throws Exception {
    Json.mapper.registerModule(new JavaTimeModule());
	FileSystem vertxFileSystem = vertx.fileSystem();
    vertxFileSystem.readFile("swagger.json", readFile -> {
        if (readFile.succeeded()) {
            Swagger swagger = new SwaggerParser().parse(readFile.result().toString(Charset.forName("utf-8")));
            SwaggerManager.getInstance().setSwagger(swagger);
            Router swaggerRouter = SwaggerRouter.swaggerRouter(Router.router(vertx), swagger, vertx.eventBus(), new OperationIdServiceIdResolver());
        
            deployVerticles(startFuture);

            vertx.createHttpServer() 
                .requestHandler(swaggerRouter::accept) 
                .listen(config().getInteger("http.port", 8080));
            startFuture.complete();
        } else {
        	startFuture.fail(readFile.cause());
        }
    });        		        
}
 
开发者ID:phiz71,项目名称:vertx-swagger,代码行数:22,代码来源:MainApiVerticle.java

示例7: testSwaggerJSON

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
@Test
public void testSwaggerJSON() {

    SutInfoDto dto = remoteController.getSutInfo();

    String swaggerJson = given().accept(Formats.JSON_V1)
            .get(dto.swaggerJsonUrl)
            .then()
            .statusCode(200)
            .extract().asString();

    Swagger swagger = new SwaggerParser().parse(swaggerJson);

    assertEquals("/api", swagger.getBasePath());
    assertEquals(2, swagger.getPaths().size());
}
 
开发者ID:EMResearch,项目名称:EvoMaster,代码行数:17,代码来源:PIManualTest.java

示例8: SwaggerDiff

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
/**
 * @param oldSpec
 * @param newSpec
 * @param auths
 * @param version
 */
private SwaggerDiff(String oldSpec, String newSpec, List<AuthorizationValue> auths,
        String version) {
    if (SWAGGER_VERSION_V2.equals(version)) {
        SwaggerParser swaggerParser = new SwaggerParser();
        oldSpecSwagger = swaggerParser.read(oldSpec, auths, true);
        newSpecSwagger = swaggerParser.read(newSpec, auths, true);
    } else {
        SwaggerCompatConverter swaggerCompatConverter = new SwaggerCompatConverter();
        try {
            oldSpecSwagger = swaggerCompatConverter.read(oldSpec, auths);
            newSpecSwagger = swaggerCompatConverter.read(newSpec, auths);
        } catch (IOException e) {
            logger.error("cannot read api-doc from spec[version_v1.x]", e);
            return;
        }
    }
    if (null == oldSpecSwagger || null == newSpecSwagger) { throw new RuntimeException(
            "cannot read api-doc from spec."); }
}
 
开发者ID:Sayi,项目名称:swagger-diff,代码行数:26,代码来源:SwaggerDiff.java

示例9: process

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
public Swagger process(String resource) {
  if (resource == null) {
    throw new IllegalArgumentException("No file or URL specified");
  }

  File file = new File(resource);

  if (!file.exists()) {
    try {
      new URL(resource);
    } catch (MalformedURLException e) {
      throw new IllegalArgumentException("File doesn't exist or invalid URL!");
    }
  }

  return new SwaggerParser().read(resource);
}
 
开发者ID:AresS31,项目名称:swurg,代码行数:18,代码来源:Loader.java

示例10: createSwagger

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
private void createSwagger(String pathToJsonFile) throws FileNotFoundException {
	swagger = new SwaggerParser().read(pathToJsonFile);

	if (swagger != null) {

		// if no scheme is defined, use http by default
		host = (swagger.getSchemes().size() >= 1 ? swagger.getSchemes().get(0).name().toLowerCase() : "http")
				+ "://" + swagger.getHost() + swagger.getBasePath();

		log.debug("Host : " + host);

		getEntryPoints();

	} else {
		throw new FileNotFoundException("Error, unable to read the Json file at : " + pathToJsonFile);
	}
}
 
开发者ID:lpelleau,项目名称:SwagTester,代码行数:18,代码来源:SwagTester.java

示例11: tryGetOpenApi

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
private static Swagger tryGetOpenApi(File file, String userDefinedFilename)
    throws OpenApiConversionException {
  try {
    Swagger swagger = new SwaggerParser().read(file.getAbsolutePath());
    if (swagger == null) {
      throw new OpenApiConversionException(
          String.format(
              "OpenAPI spec in file {%s} is ill formed and cannot be parsed",
              userDefinedFilename));
    } else {
      return swagger;
    }
  } catch (RuntimeException ex) {
    throw new OpenApiConversionException(
        String.format(
            "OpenAPI spec in file {%s} is ill formed and cannot be parsed: %s",
            userDefinedFilename, ex.getMessage()));
  }
}
 
开发者ID:googleapis,项目名称:api-compiler,代码行数:20,代码来源:MultiOpenApiParser.java

示例12: shouldCreatePropertyParametersFromPetstoreSwagger

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
@Test
public void shouldCreatePropertyParametersFromPetstoreSwagger() throws IOException {
    final String specification = resource("/petstore.json");
    final Swagger swagger = new SwaggerParser().parse(specification);

    final Parameter petIdPathParameter = swagger.getPath("/pet/{petId}").getGet().getParameters().get(0);

    final Optional<ConfigurationProperty> maybeConfigurationProperty = SwaggerConnectorGenerator
        .createPropertyFromParameter(petIdPathParameter);

    final ConfigurationProperty expected = new ConfigurationProperty.Builder()//
        .componentProperty(false)//
        .deprecated(false)//
        .description("ID of pet to return")//
        .displayName("petId")//
        .group("producer")//
        .javaType(Long.class.getName())//
        .kind("property")//
        .required(true)//
        .secret(false)//
        .type("integer")//
        .build();

    assertThat(maybeConfigurationProperty).hasValue(expected);
}
 
开发者ID:syndesisio,项目名称:syndesis-rest,代码行数:26,代码来源:SwaggerConnectorGeneratorTest.java

示例13: main

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
	SpringApplication.run(DocuDemoApplication.class, args);
	String swaggerFile = args[0];
	boolean example = FileUtil.toBoolean(args[1]);
	File file = new File(swaggerFile);
	ApiData apiData = new ApiData();
	IndexData indexData = new IndexData();
	ResponseModelData responseModelData = new ResponseModelData();

	if (file.exists()) {

		Swagger swagger = new SwaggerParser().read(swaggerFile);

		indexData.buildIndexPage(swagger);
		apiData.buildAPIPages(swagger, example);
		responseModelData.buildResponseModelPage(swagger);

		// JS and CSS files for creating tree structure for json object
		FileUtil fileUtil = new FileUtil();
		fileUtil.createLib();
		logger.info("The documentation portal is generated at this location: /docuDemo/Portal");
		System.exit(0);

	} else {
		logger.error("======================Error===============================");
		logger.error("Please input a valid file location");
		System.exit(1);
	}
	

}
 
开发者ID:AmadeusITGroup,项目名称:docu.me,代码行数:32,代码来源:DocuDemoApplication.java

示例14: writeDynamicResource

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
private byte[] writeDynamicResource(InputStream is) throws IOException {
  String str = CharStreams.toString(new InputStreamReader(is, Charsets.UTF_8));
  Swagger swagger = new SwaggerParser().parse(str);
  // set the resource listing tag
  Tag dynamic = new Tag();
  dynamic.setName("dynamic");
  dynamic.setDescription("Dynamic Cypher resources");
  swagger.addTag(dynamic);
  // add resources to the path
  Map<String,Path> paths = swagger.getPaths();
  paths.putAll(configuration.getCypherResources());
  Map<String,Path> sorted = new LinkedHashMap<>();
  List<String> keys = new ArrayList<>();
  keys.addAll(paths.keySet());
  Collections.sort(keys);
  for (String key : keys) {
    sorted.put(key, paths.get(key));
  }
  swagger.setPaths(sorted);
  // return updated swagger JSON
  return Json.pretty(swagger).getBytes();
}
 
开发者ID:SciGraph,项目名称:SciGraph,代码行数:23,代码来源:SwaggerFilter.java

示例15: OpenApiRequestMapper

import io.swagger.parser.SwaggerParser; //导入依赖的package包/类
@Autowired
public OpenApiRequestMapper(@NonNull InformationProductResourceProvider informationProductLoader,
    @NonNull SwaggerParser openApiParser, @NonNull ApplicationProperties applicationProperties,
    @NonNull GetRequestHandlerFactory getRequestHandlerFactory) {
  this.informationProductResourceProvider = informationProductLoader;
  this.openApiParser = openApiParser;
  this.applicationProperties = applicationProperties;
  this.getRequestHandlerFactory = getRequestHandlerFactory;
}
 
开发者ID:dotwebstack,项目名称:dotwebstack-framework,代码行数:10,代码来源:OpenApiRequestMapper.java


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