我使用下面的 maven 插件将 swagger 与我的应用程序集成在一起 https://github.com/martypitt/swagger-springmvc
我在我的 spring servlet xml 中配置了以下内容
<mvc:annotation-driven/> <!-- Required so swagger-springmvc can access spring's RequestMappingHandlerMapping -->
<bean class="com.mangofactory.swagger.configuration.SpringSwaggerConfig" />
<mvc:default-servlet-handler/>
<bean id="propertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations" >
<list>
<value>/WEB-INF/swagger.properties</value>
</list>
</property>
</bean>
我的招摇属性如下所示
documentation.services.basePath= http://payrollservice.com/customservice documentation.services.version=1.0
我生成的 api-docs.json 如下所示,我不确定为什么它没有基本路径以及为什么它有前缀“/default”
{
apiVersion: "1.0",
swaggerVersion: "1.2",
apis: [
{
path: "/default/custom-controller",
description: "backupset API"
}
],
info: {
title: "default Title",
description: "Api Description",
termsOfServiceUrl: "Api terms of service",
contact: "Contact Email",
license: "Licence Type",
licenseUrl: "License URL"
}
}