swagger 在apache CXF 中的使用——JAX-RS Swagger2Feature
The CXF Swagger2Feature allows you to generate Swagger 2.0 documents from JAX-RS service endpoints with a simple configuration.
见:http://cxf.apache.org/docs/swagger2feature.html JAX-RS Swagger2Feature Demo
================= The demo shows a basic usage of Swagger 2.0 API documentation with REST based Web Services using
JAX-RS 2.0 (JSR-339). Swagger UI is available at: http://localhost:9000/ Building and running the demo using Maven
--------------------------------------- From the base directory of this sample (i.e., where this README file is
located), the Maven pom.xml file can be used to build and run the demo. Using either UNIX or Windows: mvn install
mvn -Pserver (from one command line window) After the service is started, the Swagger API documents in JSON and YAML
are available at http://localhost:9000/swagger.json
http://localhost:9000/swagger.yaml To view the Swagger document using Swagger-UI, use your Browser to
open the Swagger-UI page at http://localhost:9000/api-docs?url=/swagger.json or http://localhost:9000/api-docs?url=/swagger.yaml or access it from the CXF Services page: http://localhost:9000/services
and follow a Swagger link.
例子在:https://github.com/apache/cxf/blob/master/distribution/src/main/release/samples/jax_rs/description_swagger2/src/main/java/demo/jaxrs/swagger/server/Sample.java
示意代码:
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; @Path("/sample")
@Api(value = "/sample", description = "Sample JAX-RS service with Swagger documentation")
public class Sample {
private Map<String, Item> items; public Sample() {
items = Collections.synchronizedMap(new TreeMap<String, Item>(String.CASE_INSENSITIVE_ORDER));
items.put("Item 1", new Item("Item 1", "Value 1"));
items.put("Item 2", new Item("Item 2", "Value 2"));
} @Produces({ MediaType.APPLICATION_JSON })
@GET
@ApiOperation(
value = "Get operation with Response and @Default value",
notes = "Get operation with Response and @Default value",
response = Item.class,
responseContainer = "List"
)
public Response getItems(
@ApiParam(value = "Page to fetch", required = true) @QueryParam("page") @DefaultValue("1") int page) { return Response.ok(items.values()).build();
}
}
swagger 在apache CXF 中的使用——JAX-RS Swagger2Feature的更多相关文章
- Spring 4 集成Apache CXF开发JAX-RS Web Service
什么是JAX-RS 在JSR-311规范中定义,即Java API for RESTful Web Services,一套Java API,用于开发 RESTful风格的Webservice. 工程概 ...
- Apache CXF实现WebService入门教程(附完整源码)
Apache CXF实现WebService非常简单实用,只需要几步就可以实现一个简单的web service. 首先我们需要新建一个maven项目,在pom中添加依赖和jetty作为测试的web s ...
- Apache CXF Webservice入门
1.步骤一览 关于CXF的介绍请移步官网.百科,这里仅供初次使用者入门. 2.步骤详情 2.1.环境准备 apache-cxf-3.0.0.zip下载 jdk1.7.0_51 Eclipse4.3.0 ...
- 在cxf中使用配置避免增加字段导致客户端必须更新、同步实体属性的问题
在使用cxf实现webservice时,经常碰到的问题就是如果在服务端,修改了一个接口的签名实现,如增加一个字段,或者删除一个字段.在这种情况下,在默认的配置中,就会报以下的错误信息: org.apa ...
- Apache CXF自定义拦截器
为什么设计拦截器?1.为了在webservice请求过程中,能动态操作请求和响应数据,CXF设计了拦截器 拦截器分类: 1.按所处的位置分:服务器端拦截器,客户端拦截器. 2.按消息的方向分:入拦截器 ...
- apache CXF wsdl2java工具的使用
cxf的wsdl2java命令和JDK的wsimport命令的区别和使用 JDK提供了一个wsimport.exe的命令,主要是用于将WebService生成客户端代码,然后好调用WebService ...
- 解决Apache CXF 不支持传递java.sql.Timestamp和java.util.HashMap类型问题
在项目中使用Apache开源的Services Framework CXF来发布WebService,CXF能够很简洁与Spring Framework 集成在一起,在发布WebService的过程中 ...
- Apache CXF 103 CXF Basics - partial
本Spike记录中内容,如无特别指出,均引用[1]. 0 引言 0.1 基本的Web服务术语 XML 业界的结构化交换信息表示的事实上的标准. XML namespace是在XML文档中提供唯一的命名 ...
- Apache CXF 102 CXF with REST
前言 续上篇Apache CXF 101,摘抄部分REST概念性知识,以运行实例考察CXF对REST的支持. 目录 1 REST简介 2 工具 3 运行实例 内容 本Spike记录中内容,如无特别指出 ...
随机推荐
- 开发人员必备的 Chrome 扩展
Firebug:不用多介绍了吧 https://chrome.google.com/webstore/detail/bmagokdooijbeehmkpknfglimnifench ChromeSni ...
- ApexSQL Log 从意外UPDATE和DELETE操作中恢复SQL Server数据
下载地址:https://www.apexsql.com/download.aspx 如何从意外UPDATE和DELETE操作中恢复SQL Server数据 ApexSQL Log 从意外UPDATE ...
- Docker基础入门实践
原文地址 基本概念 Docker三个基本概念 镜像(Image) 容器(Container) 仓库(Repository) 镜像 镜像可以理解为只读模板,如包含一个centos操作系统环境 容器 Do ...
- [JavaScript]常用的页面倒计时
倒计时是web开发中比较常用的,以下列出常用的几个倒计时方法,仅供参考: 一 :页面倒计时 原理一般都是通过 setTimeout 或 setInterval 函数实现,下面是一个最简单的倒计时 &l ...
- iOS 关于 Missing iOS Distribution signing identity for.... 等 打包 校验 出现的事故 处理经验
着实郁闷了一阵子,不知道为什么 证书和配置文件都没有问题 在Archieve后 validate 提示:"Missing iOS Distribution signing identity ...
- UnsatisfiedLinkError X.so is 64-bit instead of 32-bit之Android 64 bit SO加载机制
http://blog.csdn.net/canney_chen/article/details/50633982 今天用户反馈应用闪退崩溃了.然后找呀找… 过程原来是这样的: 还是说下项目背景 应用 ...
- 【Flask】ORM 关系一对一
### 一对一的关系:在sqlalchemy中,如果想要将两个模型映射成一对一的关系,那么应该在父模型中,指定引用的时候,要传递一个`uselist=False`这个参数进去.就是告诉父模型,以后引用 ...
- PHP辅攻_[学习资料收集]PHP连接SQLServer2005方法
PHP连接SQLServer2005 1.修改php.ini将extension=php_mssql.dll的注释删除保存. 修改php.in将mssql.secure_connection = Of ...
- 转移灶,原发灶,cfDNA的外显子测序得到的突变点的关系
文章名称:Exome Sequencing of Cell-Free DNA from Metastatic Cancer Patients IdentifiesClinically Actionab ...
- 大话设计模式之PHP篇 - 单例模式
在编写PHP代码的时候,经常使用new关键字实例化一个对象,比如 <?php Class Database { } $db = new Database; 这是最常规的实例化操作方法,像数据库操 ...