我正在使用 Swagger 提供的出色的swagger2markup插件为我的 REST API 生成 Asciidoc 文档。我遵循了 swagger2markup 文档,并且正在使用 Spring MVC 集成测试从我的 Springfox Swagger 端点生成标记,如下所示(我正在使用 Maven):
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = { AppConfig.class, SwaggerConfig.class })
public class DocumentationIT {
protected MockMvc mockMvc;
@Autowired
protected WebApplicationContext webApplicationContext;
@Rule
public JUnitRestDocumentation restDocumentation = new JUnitRestDocumentation("src/docs/asciidoc/apidoc/generated-snippets");
@Before
public void setUp(){
this.mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
.apply(documentationConfiguration(this.restDocumentation))
.build();
}
@Test
public void convertSwaggerToAsciiDoc() throws Exception {
this.mockMvc.perform(get("/v2/api-docs")
.accept(MediaType.APPLICATION_JSON))
.andDo(
Swagger2MarkupResultHandler
.outputDirectory("src/docs/asciidoc/apidoc")
.withExamples("src/docs/asciidoc/apidoc/generated-snippets").build())
.andExpect(status().isOk());
}
}
一切都很好,我的所有路径都在我的最终文档中,但是路径都直接出现在根目录中,并且没有按资源分组(即按控制器),因此Method 1
from将出现在与fromController 1
相同的级别。Method 2
Controller 2
我的输出:
我想要什么:
据我所见,当使用从本地文件生成时,如在这个swagger2-markup Maven 项目模板中,您可以指定一个属性来告诉 swagger2markup 使用 config 属性按标签对路径进行分组<swagger2markup.pathsGroupedBy>TAGS</swagger2markup.pathsGroupedBy>
,但是似乎没有这样的配置Swagger2MarkupResultHandler
从测试中使用时。唯一的选择是withMarkupLanguage()
,但没有withPathsGroupedBy()
方法......
我在这里错过了什么吗?