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

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

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

OpenAPI.addExtension介绍

暂无

代码示例

代码示例来源: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: com.atlassian.swagger/atlassian-swagger-doclet

public OpenAPI addNarrativeDocs(OpenAPI openAPI) {
    if (docletOptions.hasNarrativeDocs()) {
      openAPI.addExtension("x-atlassian-narrative", docletOptions.getNarrativeDocs());
    }
    return openAPI;
  }
}

相关文章