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

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

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

OpenAPI.setServers介绍

暂无

代码示例

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

AnnotationsUtils.getServers(openAPIDefinition.servers()).ifPresent(servers -> openAPI.setServers(servers));

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

clone.setExternalDocs(openAPI.getExternalDocs());
clone.setSecurity(openAPI.getSecurity());
clone.setServers(openAPI.getServers());
clone.tags(filteredOpenAPI.getTags() == null ? null : new ArrayList<>(openAPI.getTags()));

代码示例来源:origin: apache/cxf

public OpenAPIConfiguration customize(final OpenAPIConfiguration configuration) {
  if (configuration == null) {
    return configuration;
  }
  if (dynamicBasePath) {
    final MessageContext ctx = createMessageContext();
    // If the JAX-RS application with custom path is defined, it might be present twice, in the 
    // request URI as well as in each resource operation URI. To properly represent server URL, 
    // the application path should be removed from it.
    final String url = StringUtils.removeEnd(
        StringUtils.substringBeforeLast(ctx.getUriInfo().getRequestUri().toString(), "/"),
        applicationPath);
    final Collection<Server> servers = configuration.getOpenAPI().getServers();
    if (servers == null || servers.stream().noneMatch(s -> s.getUrl().equalsIgnoreCase(url))) {
      configuration.getOpenAPI().setServers(Collections.singletonList(new Server().url(url)));
    }
  }
  return configuration;
}

代码示例来源:origin: org.apache.syncope.core/syncope-core-rest-cxf

@Override
public OpenAPIConfiguration customize(final OpenAPIConfiguration configuration) {
  super.customize(configuration);
  MessageContext ctx = JAXRSUtils.createContextValue(
      JAXRSUtils.getCurrentMessage(), null, MessageContext.class);
  String url = StringUtils.substringBeforeLast(ctx.getUriInfo().getRequestUri().getRawPath(), "/");
  configuration.getOpenAPI().setServers(Collections.singletonList(new Server().url(url)));
  return configuration;
}

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

private void fixPathAndServerUrls(OpenAPI openAPI) {
  String baseUrl = getBaseUrlFromServerUrls(openAPI);
  Map<String, PathItem> prefixedPaths = openAPI.getPaths().entrySet().stream()
      .map(entry -> new AbstractMap.SimpleEntry<>(baseUrl + entry.getKey(), entry.getValue()))
      .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue));
  Paths paths = new Paths();
  paths.putAll(prefixedPaths);
  openAPI.setPaths(paths);
  List<Server> servers = openAPI.getServers()
      .stream()
      .map(server -> {
        String url = server.getUrl();
        return new Server()
            .url(url.substring(0, url.indexOf(baseUrl) > 0 ? url.indexOf(baseUrl) : 0))
            .description(server.getDescription());
      })
      .collect(Collectors.toList());
  openAPI.setServers(servers);
}

代码示例来源:origin: org.apache.cxf/cxf-rt-rs-service-description-openapi-v3

public OpenAPIConfiguration customize(final OpenAPIConfiguration configuration) {
  if (configuration == null) {
    return configuration;
  }
  if (dynamicBasePath) {
    final MessageContext ctx = createMessageContext();
    // If the JAX-RS application with custom path is defined, it might be present twice, in the 
    // request URI as well as in each resource operation URI. To properly represent server URL, 
    // the application path should be removed from it.
    final String url = StringUtils.removeEnd(
        StringUtils.substringBeforeLast(ctx.getUriInfo().getRequestUri().toString(), "/"),
        applicationPath);
    final Collection<Server> servers = configuration.getOpenAPI().getServers();
    if (servers == null || servers.stream().noneMatch(s -> s.getUrl().equalsIgnoreCase(url))) {
      configuration.getOpenAPI().setServers(Collections.singletonList(new Server().url(url)));
    }
  }
  return configuration;
}

代码示例来源: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: swagger-api/swagger-parser

openAPI.setServers(getServersList(array, String.format("%s.%s", location, "servers"), result, path));
}else {
  Server defaultServer = new Server();
  List<Server>  servers = new ArrayList<>();
  servers.add(defaultServer);
  openAPI.setServers(servers);

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

openAPI.setServers(getServersList(array, String.format("%s.%s", location, "servers"), result, path));
}else {
  Server defaultServer = new Server();
  List<Server>  servers = new ArrayList<>();
  servers.add(defaultServer);
  openAPI.setServers(servers);

代码示例来源:origin: org.openapitools.swagger.parser/swagger-parser-v3

openAPI.setServers(getServersList(array, String.format("%s.%s", location, "servers"), result, path));
}else {
  Server defaultServer = new Server();
  List<Server>  servers = new ArrayList<>();
  servers.add(defaultServer);
  openAPI.setServers(servers);

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

AnnotationsUtils.getServers(openAPIDefinition.servers()).ifPresent(servers -> openAPI.setServers(servers));

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

AnnotationsUtils.getServers(openAPIDefinition.servers()).ifPresent(servers -> openAPI.setServers(servers));

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

openAPI.setServers(convert(swagger.getSchemes(), swagger.getHost(), swagger.getBasePath()));

代码示例来源:origin: io.swagger.parser.v3/swagger-parser-v2-converter

openAPI.setServers(convert(swagger.getSchemes(), swagger.getHost(), swagger.getBasePath()));

代码示例来源:origin: org.openapitools.swagger.parser/swagger-parser-v2-converter

openAPI.setServers(convert(swagger.getSchemes(), swagger.getHost(), swagger.getBasePath()));

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

clone.setExternalDocs(openAPI.getExternalDocs());
clone.setSecurity(openAPI.getSecurity());
clone.setServers(openAPI.getServers());
clone.tags(filteredOpenAPI.getTags() == null ? null : new ArrayList<>(openAPI.getTags()));

相关文章