io.swagger.v3.oas.models.OpenAPI.<init>()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(160)

本文整理了Java中io.swagger.v3.oas.models.OpenAPI.<init>()方法的一些代码示例,展示了OpenAPI.<init>()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。OpenAPI.<init>()方法的具体详情如下:
包路径:io.swagger.v3.oas.models.OpenAPI
类名称:OpenAPI
方法名:<init>

OpenAPI.<init>介绍

暂无

代码示例

代码示例来源:origin: swagger-api/swagger-core

public Reader() {
  this.openAPI = new OpenAPI();
  paths = new Paths();
  openApiTags = new LinkedHashSet<>();
  components = new Components();
}

代码示例来源:origin: swagger-api/swagger-core

@Test
public void testExtension() throws Exception {
  OpenAPI swagger = new OpenAPI();
  swagger.addExtension("x-foo-bar", "foo bar");
  swagger.setInfo(new Info());
  swagger.getInfo().addExtension("x-foo-bar", "foo bar");
  String swaggerJson = Json.mapper().writeValueAsString(swagger);
  assertFalse(swaggerJson.contains("extensions"));
  OpenAPI rebuilt = Json.mapper().readValue(swaggerJson, OpenAPI.class);
  assertEquals(rebuilt.getExtensions().values().iterator().next(), "foo bar");
  assertEquals(rebuilt.getInfo().getExtensions().values().iterator().next(), "foo bar");
}

代码示例来源:origin: swagger-api/swagger-core

@Test
public void testSerializeASpecWithPathReferences() throws Exception {
  OpenAPI swagger = new OpenAPI()
      .addServersItem(new Server().url("http://petstore.swagger.io"));
  PathItem expectedPath = new PathItem().$ref("http://my.company.com/paths/health.json");
  swagger.path("/health", expectedPath);
  String swaggerJson = Json.mapper().writeValueAsString(swagger);
  OpenAPI rebuilt = Json.mapper().readValue(swaggerJson, OpenAPI.class);
  final PathItem path = rebuilt.getPaths().get("/health");
  assertEquals(path, expectedPath);
}

代码示例来源:origin: swagger-api/swagger-core

@Test
  public void testSerializeASpecWithResponseReferences() throws Exception {
    OpenAPI swagger = new OpenAPI()
        .addServersItem(new Server().url("http://petstore.swagger.io"));

    ApiResponse expectedResponse = new ApiResponse().$ref("http://my.company.com/paths/health.json");
    PathItem expectedPath = new PathItem()
        .get(
            new Operation().responses(
                new ApiResponses()
                    .addApiResponse("200", expectedResponse)));

    swagger.path("/health", expectedPath);

    String swaggerJson = Json.mapper().writeValueAsString(swagger);
    OpenAPI rebuilt = Json.mapper().readValue(swaggerJson, OpenAPI.class);

    assertEquals(rebuilt.getPaths().get("/health").getGet().getResponses().get("200"), expectedResponse);

  }
}

代码示例来源:origin: swagger-api/swagger-core

OpenAPI clone = new OpenAPI();
clone.info(filteredOpenAPI.getInfo());
clone.openapi(filteredOpenAPI.getOpenapi());

代码示例来源:origin: swagger-api/swagger-core

info.setContact(contact);
final OpenAPI swagger = new OpenAPI()
    .info(info)
    .addServersItem(new Server().url("http://petstore.swagger.io"))

代码示例来源:origin: swagger-api/swagger-core

info.addExtension("x-test", "value");
final OpenAPI swagger = new OpenAPI()
    .info(info)
    .addServersItem(new Server()

代码示例来源:origin: swagger-api/swagger-core

info.setContact(contact);
final OpenAPI oas = new OpenAPI()
    .info(info)
    .addServersItem(new Server()

代码示例来源:origin: com.atlassian.swagger/atlassian-swagger-doclet

public OpenAPI readTemplate(String swaggerTemplateFile) {
  OpenAPI swaggerTemplate = new OpenAPI();
  if (!StringUtils.isEmpty(swaggerTemplateFile)) {
    swaggerTemplate = requireNonNull(readTemplateImpl(swaggerTemplateFile));
  }
  return swaggerTemplate;
}

代码示例来源:origin: io.swagger.core.v3/swagger-jaxrs2

public Reader() {
  this.openAPI = new OpenAPI();
  paths = new Paths();
  openApiTags = new LinkedHashSet<>();
  components = new Components();
}

代码示例来源:origin: noboomu/proteus

public Reader()
  {
// Json.mapper().addMixIn(ServerRequest.class, ServerRequestMixIn.class);

    this.openAPI = new OpenAPI();
    paths = new Paths();
    openApiTags = new LinkedHashSet<>();
    components = new Components();

  }

代码示例来源:origin: com.holon-platform.jaxrs/documentation-jaxrs

public ApiConfigV3Group1() {
  super();
  setOpenAPI(new OpenAPI().info(new Info().title("API group 1")));
  setResourcePackages(Collections.singleton("my.resource.package.group1"));
}

代码示例来源:origin: com.holon-platform.jaxrs/documentation-jaxrs

public ApiConfigV3Group2() {
  super();
  setOpenAPI(new OpenAPI().info(new Info().title("API group 2")));
  setResourcePackages(Collections.singleton("my.resource.package.group2"));
}

代码示例来源:origin: com.holon-platform.jaxrs/documentation-jaxrs

public ApiConfigV3() {
  super();
  setOpenAPI(new OpenAPI().info(new Info().title("Test bean config").version("1.0.0")));
}

代码示例来源:origin: com.holon-platform.jaxrs/documentation-jaxrs

public ApiConfigV3b() {
  super();
  setOpenAPI(new OpenAPI().info(new Info().title("Test bean config").version("1.0.0")));
}

代码示例来源:origin: noboomu/proteus

@SuppressWarnings("rawtypes")
protected void generateSpec() throws Exception
{
  Set<Class<?>> classes = this.registeredControllers;
  OpenAPIExtensions.setExtensions(Collections.singletonList(new ServerParameterExtension()));
  OpenAPI openApi = new OpenAPI();
  Info info = mapper.convertValue(openAPIConfig.getValue("info").unwrapped(), Info.class);
  openApi.setInfo(info);
  Map<String, SecurityScheme> securitySchemes = mapper.convertValue(    openAPIConfig.getValue("securitySchemes").unwrapped(),new TypeReference<Map<String, SecurityScheme>>(){});
  if (openApi.getComponents() == null)
  {
    openApi.setComponents(new Components());
  }
  openApi.getComponents().setSecuritySchemes(securitySchemes);
  List<Server> servers = mapper.convertValue(openAPIConfig.getValue("servers").unwrapped(), new TypeReference<List<Server>>(){});
  openApi.setServers(servers);
  SwaggerConfiguration config = new SwaggerConfiguration().resourceClasses(classes.stream().map(Class::getName).collect(Collectors.toSet())).openAPI(openApi);
  config.setModelConverterClassess(Collections.singleton(ServerModelResolver.class.getName()));
  OpenApiContext ctx = new GenericOpenApiContext().openApiConfiguration(config)
      .openApiReader(new Reader(config))
      .openApiScanner(new JaxrsApplicationAndAnnotationScanner().openApiConfiguration(config))
      .init();
  openApi = ctx.read();
  this.openApi = openApi;
  this.spec = writer.writeValueAsString(openApi);
}

代码示例来源:origin: org.mycore/mycore-restapi

private void setupOAS() {
  OpenAPI oas = new OpenAPI();
  Info oasInfo = new Info();
  oas.setInfo(oasInfo);

代码示例来源:origin: io.github.amyassist/amy-http-server

OpenAPI openapi = new OpenAPI();

代码示例来源:origin: com.holon-platform.jaxrs/documentation-jaxrs

public void apireaderv3() {
  // tag::apireaderv3[]
  SwaggerConfiguration configuration = new SwaggerConfiguration();
  configuration.setOpenAPI(new OpenAPI().info(new Info().title("The title").version("1")));
  ApiReader<OpenAPI> reader = SwaggerV3.reader(configuration); // <1>
  OpenAPI api = reader.read(ApiEndpoint1.class, ApiEndpoint2.class); // <2>
  String json = SwaggerV3.asJson(api); // <3>
  String yaml = SwaggerV3.asYaml(api); // <4>
  // end::apireaderv3[]
}

代码示例来源:origin: ppdai-incubator/raptor

/**
   * https://github.com/OAI/OpenAPI-SpecOpenApiification/blob/master/versions/3.0.1.md#openapi-object
   *
   * @param service
   * @param protoFile
   * @return
   */
  protected OpenAPI getOpenApi(Service service, ProtoFile protoFile) {
    refHelper.set(new RefHelper(schmea, protoFile, service));

    OpenAPI openApi = new OpenAPI();

    //required
    openApi.info(getInfo(protoFile, service));
    openApi.paths(getPath(protoFile, service));

    //optional
    openApi.servers(getServers());
    openApi.components(getComponents());
//        openApi.security()
    openApi.tags(getTags());
//        openApi.externalDocs(getExternalDocumentation());

    return openApi;
  }

相关文章