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记录中内容,如无特别指出 ...
随机推荐
- ExtJS4 给同一个formpanel不同的url
formpanel能够这样使用,api上的样例: var panel=Ext.create('Ext.form.Panel', { title: 'Simple Form', bodyPadding: ...
- Js前台页面搜索
$("#filter").on("keyup",function(){$(".aimed_list").hide().filter(&quo ...
- Sql Server 2005 .bak备份文进行还原数据库
https://jingyan.baidu.com/article/9158e000250b91a25412283f.html https://www.cnblogs.com/webmen/p/575 ...
- python基础26 -----python进程及协成
一.进程 1.multiprocessing模块实现多进程并发. 1.1multiprocessing包是Python中的多进程管理包,与threading.Thread类似,它可以利用multipr ...
- 剑指offer 面试41题
面试41题: 题目:数据流中的中位数 题:如何得到一个数据流中的中位数?如果从数据流中读出奇数个数值,那么中位数就是所有数值排序之后位于中间的数值.如果从数据流中读出偶数个数值,那么中位数就是所有数值 ...
- django 操作前端数据
django 利用json处理前端页面数据,FLASK当中也同样 def create_company(request):if request.user.is_superuser:custom_l ...
- LeetCode:平衡二叉树【110】
LeetCode:平衡二叉树[110] 题目描述 给定一个二叉树,判断它是否是高度平衡的二叉树. 本题中,一棵高度平衡二叉树定义为: 一个二叉树每个节点 的左右两个子树的高度差的绝对值不超过1. 示例 ...
- Spring AOP 学习(一) 代理模式
AOP为Aspect Oriented Programming的缩写,意为:面向切面编程(也叫面向方面),可以通过预编译方式和运行期动态代理实现在不修改源代码的情况下给程序动态统一添加功能的一种技术. ...
- 'substring(from:)' is deprecated: Please use String slicing subscript with a 'partial range from' operator.
let newStr = String(str[..<index]) // = str.substring(to: index) In Swift 3 let newStr = String(s ...
- Keepalived + LVS/DR 安装配置
Keepalived + LVS/DR 说明 Keepalived:可以踢出掉故障服务 Keepalived:可以实现主从切换,解决单点故障 实验环境 四台主机:Linux Centos 6.4 32 ...