导航:首页 > 源码编译 > api在线文档源码

api在线文档源码

发布时间:2022-07-29 03:08:49

⑴ 如何生成RestFul Api文档

还是喜欢使用WisdomToolRESTClientV1.1支持自动化测试RESTfulAPI和自动生成RESTfulAPI文档

工具地址:

https://github.com/wisdomtool/rest-client/


⑵ 如何使 WebAPI 自动生成漂亮又实用在线API文档

1.1 SwaggerUI

SwaggerUI 是一个简单的Restful API 测试和文档工具。简单、漂亮、易用(官方demo)。通过读取JSON 配置显示API. 项目本身仅仅也只依赖一些 html,css.js静态文件. 你可以几乎放在任何Web容器上使用。

1.2 Swashbuckle

Swashbuckle 是.NET类库,可以将WebAPI所有开放的控制器方法生成对应SwaggerUI的JSON配置。再通过SwaggerUI 显示出来。类库中已经包含SwaggerUI 。所以不需要额外安装。

2.快速开始

创建项目 OnlineAPI来封装网络音乐服务(示例下载) ,通过API可以搜索、获取音乐的信息和播放连接。

我尽量删除一些我们demo中不会用到的一些文件,使其看上去比较简洁。

WebAPI 安装 Swashbuckle

Install-Package Swashbuckle

代码注释生成文档说明。
Swashbuckle 是通过生成的XML文件来读取注释的,生成 SwaggerUI,JSON 配置中的说明的。
安装时会在项目目录 App_Start 文件夹下生成一个 SwaggerConfig.cs 配置文件,用于配置 SwaggerUI 相关展示行为的。如图:

将配置文件大概99行注释去掉并修改为
c.IncludeXmlComments(GetXmlCommentsPath(thisAssembly.GetName().Name));

并在当前类中添加一个方法

/// <summary>
/// </summary>
/// <param name="name"></param>
/// <returns></returns>
protected static string GetXmlCommentsPath(string name)
{
return string.Format(@"{0}\bin\{1}.XML", AppDomain.CurrentDomain.BaseDirectory, name);
}

紧接着你在此Web项目属性生成选卡中勾选 “XML 文档文件”,编译过程中生成类库的注释文件

添加网络音乐 3个API

访问 http://<youhost>/swagger/ui/index,最终显示效果

我们通过API 测试API 是否成功运行

3.添加自定义HTTP Header

在开发移动端 API时常常需要验证权限,验证参数放在Http请求头中是再好不过了。WebAPI配合过滤器验证权限即可

首先我们需要创建一个 IOperationFilter 接口的类。IOperationFilter
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http;
using System.Web.Http.Description;
using System.Web.Http.Filters;
using Swashbuckle.Swagger;

namespace OnlineAPI.Utility
{
public class HttpHeaderFilter : IOperationFilter
{
public void Apply(Operation operation, SchemaRegistry
schemaRegistry, ApiDescription apiDescription)
{
if (operation.parameters == null) operation.parameters = new
List<Parameter>();
var filterPipeline =
apiDescription.ActionDescriptor.GetFilterPipeline();
//判断是否添加权限过滤器
var isAuthorized = filterPipeline.Select(filterInfo =>
filterInfo.Instance).Any(filter => filter is IAuthorizationFilter);
//判断是否允许匿名方法
var allowAnonymous =
apiDescription.ActionDescriptor.GetCustomAttributes<AllowAnonymousAttribute>().Any();

if (isAuthorized && !allowAnonymous)
{
operation.parameters.Add(new Parameter
{
name = "access-key",
@in = "header",
description = "用户访问Key",
required = false,
type = "string"
});
}
}
}
}

在 SwaggerConfig.cs 的 EnableSwagger 配置匿名方法类添加一行注册代码
c.OperationFilter<HttpHeaderFilter>();

添加Web权限过滤器
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text;
using System.Web;
using System.Web.Http;
using System.Web.Http.Controllers;
using Newtonsoft.Json;

namespace OnlineAPI.Utility
{
/// <summary>
///
/// </summary>
public class AccessKeyAttribute : AuthorizeAttribute
{
/// <summary>
/// 权限验证
/// </summary>
/// <param name="actionContext"></param>
/// <returns></returns>
protected override bool IsAuthorized(HttpActionContext actionContext)
{
var request = actionContext.Request;
if (request.Headers.Contains("access-key"))
{
var accessKey = request.Headers.GetValues("access-key").SingleOrDefault();
//TODO 验证Key
return accessKey == "123456789";
}
return false;
}

/// <summary>
/// 处理未授权的请求
/// </summary>
/// <param name="actionContext"></param>
protected override void HandleUnauthorizedRequest(HttpActionContext actionContext)
{
var content = JsonConvert.SerializeObject(new {State = HttpStatusCode.Unauthorized});
actionContext.Response = new HttpResponseMessage
{
Content = new StringContent(content, Encoding.UTF8, "application/json"),
StatusCode = HttpStatusCode.Unauthorized
};
}
}
}

在你想要的ApiController 或者是 Action 添加过滤器
[AccessKey]

最终显示效果

4.显示上传文件参数

SwaggerUI 有上传文件的功能和添加自定义HTTP Header 做法类似,只是我们通过特殊的设置来标示API具有上传文件的功能
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Http.Description;
using Swashbuckle.Swagger;

namespace OnlineAPI.Utility
{
/// <summary>
///
/// </summary>
public class UploadFilter : IOperationFilter
{

/// <summary>
/// 文件上传
/// </summary>
/// <param name="operation"></param>
/// <param name="schemaRegistry"></param>
/// <param name="apiDescription"></param>
public void Apply(Operation operation, SchemaRegistry schemaRegistry, ApiDescription apiDescription)
{
if (!string.IsNullOrWhiteSpace(operation.summary) && operation.summary.Contains("upload"))
{
operation.consumes.Add("application/form-data");
operation.parameters.Add(new Parameter
{
name = "file",
@in = "formData",
required = true,
type = "file"
});
}
}
}
}

在 SwaggerConfig.cs 的 EnableSwagger 配置匿名方法类添加一行注册代码
c.OperationFilter<UploadFilter>();

API 文档展示效果

⑶ 如何在Eclipse中查看java类库的源代码以及相应的api

有些类库可以查看,有些本来就不可以查看的,可以查看的,你可以用解压工具试试

⑷ API是什么API服务是什么

API就是操作系统留给应用程序的一个调用接口,应用程序通过调用操作系统的API而使操作系统去执行应用程序的命令(动作)。

API除了有"应用程序接口"的意思外,还特指 API的说明文档,也称为帮助文档。另外,也是美国石油协会、空气污染指数、医药、空中位置指示器的英文简称。

作用是提供应用程序与开发人员基于某软件或硬件得以访问一组例程的能力,而又无需访问源码,或理解内部工作机制的细节。

⑸ 求java api 文档中文版在线浏览地址

http://www.cjsdn.net/Doc/JDK60/

⑹ 如何使用go-swagger 生成Api文档

看来你还没理解maven,maven的设计思想之一是”约定优于配置“,最大优势在于”依赖管理“。archetype这个插件里面就是内置了一些app,web-app的类型,maven把他认为的最佳实践都内置好了,你所做的是按照约定把该放的东西放到位置,当然你也可以像你说的把一些代码改地方,你可以仔细研究一下archetype插件的文档中一些参数,不过maven官方不推荐改动,因为大家都遵循差不多的规定,然后在pom.xml里面很简单的就配置好依赖关系,工程的扩展就容易了。maven希望是你把你的工程源代码按照maven建好的目录进行组织即可,如果这些不适合,你可以再看看其他插件里有没有合适的。你要是那样用,还不如用ant,怎么设置工程是活的,maven并不是取代ant,只是它用了另一套哲学。不知道你认同否

⑺ java api在线中文版文档手册谁有,java api的

在线没中文的

要中文的我可以发CHM给你

这个是英文在线的

http://java.sun.com/javase/reference/api.jsp

居然成Oracle的了0 0!
http://download.oracle.com/javase/6/docs/api/

⑻ 跪求 javaapi1.7文档 中文版

JAVA帮助文档全系列 JDK1.5 JDK1.6 JDK1.7 官方中英完整版下载
JDK(Java Development Kit,Java开发包,Java开发工具)是一个写Java的applet和应用程序的程序开发环境。它由一个处于操作系统层之上的运行环境还有开发者编译,调试和运行用Java语言写的applet和应用程序所需的工具组成。

JDK(Java Development Kit)是Sun Microsystems针对Java开发员的产品。自从Java推出以来,JDK已经成为使用最广泛的Java SDK(Software development kit)。

JDK包含的基本组件包括:

·javac – 编译器,将源程序转成字节码

·jar – 打包工具,将相关的类文件打包成一个文件

·javadoc – 文档生成器,从源码注释中提取文档

·jdb – debugger,查错工具

JDK中还包括完整的JRE(Java Runtime Environment,Java运行环境),也被称为private runtime。包括了用于产品环境的各种库类,以及给开发员使用的补充库,如国际化的库、IDL库。

JDK中还包括各种例子程序,用以展示Java API中的各部分。

JDK 官方下载
JDK1.5 :
http://cds.sun.com/is-bin/INTERSHOP.enfinity/WFS/CDS-CDS_Developer-Site/en_US/-/USD/VerifyItem-Start/jdk-1_5_0_07-windows-i586-p.exe?BundledLineItemUUID=1Y5IBe.moNgAAAEhQaQH6rQU&OrderID=BjFIBe.miUsAAAEhJaQH6rQU&ProctID=83HACUFBFwsAAAEYQNw5AXuM&FileName=/jdk-1_5_0_07-windows-i586-p.exe

JDK1.6:
http://www.java.net/download/jdk6/6u10/promoted/b32/binaries/jdk-6u10-rc2-bin-b32-windows-i586-p-12_sep_2008.exe

JDK 1.7 :
http://www.java.net/download/jdk7/archive/b134/binaries/jdk-7-ea-bin-b134-windows-i586-17_mar_2011.exe
http://www.java.net/download/jdk7/archive/b138/binaries/jdk-7-ea-bin-b138-windows-i586-14_apr_2011.exe
http://download.oracle.com/otn-pub/java/jdk/7/jdk-7-windows-i586.exe

JDK API 帮助文档 :

JDK 5 :
Java SE 5 API 中文版 CHM 下载:http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/builds/JDK_API_1_5_zh_CN.CHM
JAVASE5 EN Downloads: http://javadoc.allimant.org/dist/jdk150.zip

JDK 6 :

JDK6 API 中文版下载: https://jdk-api-zh-cn.dev.java.net/
JDK6 API 中文版 HTML 格式在线文档:http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/builds/latest/html/zh_CN/api/
JDK6 API 中文版zip 格式下载: http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/builds/latest/html_zh_CN.zip
JDK6 API CHM中文参考下载:http://chinesedocument.com/upimg/soft/JDK6API中文参考070114.rar
Java SE 6 API 中文版 CHM 下载:http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/publish/1.6.0/chm/JDK_API_1_6_zh_CN.CHM

ZIP格式:http://download.java.net/jdk/jdk-api-localizations/jdk-api-zh-cn/publish/1.6.0/html_zh_CN.zip
English Version : http://javadoc.allimant.org/dist/j2se6.zip

JDK 7 :
English Verson: http://download.java.net/jdk7/docs/api/
http://www.java.net/download/jdk7/archive/b138/jdk-7-ea-bin-b138-apidocs-14_apr_2011.zip

有关JDK 的具体详细版本信息和JDK 全部版本的下载地址请参考以下网址:
http://java.sun.com/javase/downloads/index.jsp
http://java.sun.com/procts/archive/
http://www.allimant.org/javadoc/index.php
http://www.oracle.com/technetwork/java/javase/downloads/java-se-jdk-7-download-432154.html

⑼ 请教在线文档的api

android中文版
api手册地址:http://www.matools.com/api/android

Ant最新版
api手册地址:http://www.matools.com/api/ant

ASM字节码操作
api手册地址:http://www.matools.com/api/asm

Axis2最新版
api手册地址:http://www.matools.com/api/axis2

Bash脚本
api手册地址:http://www.matools.com/api/bash

Bootstrap 3
api手册地址:http://www.matools.com/api/bootstrap3

Bootstrap 4
api手册地址:http://www.matools.com/api/bootstrap4

C/C++
api手册地址:http://www.matools.com/api/c

C3P0连接池
api手册地址:http://www.matools.com/api/c3p0

CentOS使用文档
api手册地址:http://www.matools.com/api/centos

Commons-Beanutils
api手册地址:http://www.matools.com/api/commons-beanutils

Commons-Fileupload
api手册地址:http://www.matools.com/api/commons-fileupload

Commons-IO最新版
api手册地址:http://www.matools.com/api/commons-io

Commons-Lang最新版
api手册地址:http://www.matools.com/api/commons-long

Commons-Net最新版
api手册地址:http://www.matools.com/api/commons-net

CSS 3
api手册地址:http://www.matools.com/api/css

DBCP连接池
api手册地址:http://www.matools.com/api/dbcp

Dom4j
api手册地址:http://www.matools.com/api/dom4j

bbo中文文档
api手册地址:http://www.matools.com/api/bbo

EhCache
api手册地址:http://www.matools.com/api/ehcache

Freemarker
api手册地址:http://www.matools.com/api/freemarker

Go语言
api手册地址:http://www.matools.com/api/go

Hadoop
api手册地址:http://www.matools.com/api/hadoop

Hibernate中文版
api手册地址:http://www.matools.com/api/hibernate

IKAnalyzer中文版
api手册地址:http://www.matools.com/api/ikanalyzer

Java 10
api手册地址:http://www.matools.com/api/java10

Java 6
api手册地址:http://www.matools.com/api/java6

Java 7
api手册地址:http://www.matools.com/api/java7

Java 8中文版
api手册地址:http://www.matools.com/api/java8

jqGrid中文版
api手册地址:http://www.matools.com/api/jqgrid

Jquery中文版
api手册地址:http://www.matools.com/api/jquery

Json-lib
api手册地址:http://www.matools.com/api/json-lib

Junit4最新版
api手册地址:http://www.matools.com/api/junit

Kryo
api手册地址:http://www.matools.com/api/kryo

Log4j最新版
api手册地址:http://www.matools.com/api/log4j

Lucene
api手册地址:http://www.matools.com/api/lucene

Maven
api手册地址:http://www.matools.com/api/maven

Windows MFC中文版
api手册地址:http://www.matools.com/api/msdn

Mybatis
api手册地址:http://www.matools.com/api/mybatis

MySql中文版
api手册地址:http://www.matools.com/api/mysql

Netty 3.6
api手册地址:http://www.matools.com/api/netty

Nginx中文版
api手册地址:http://www.matools.com/api/nginx

OpenJPA最新版
api手册地址:http://www.matools.com/api/openjpa

PHP中文版
api手册地址:http://www.matools.com/api/php

POI-apache
api手册地址:http://www.matools.com/api/poi

QuickServer
api手册地址:http://www.matools.com/api/quickserver

redis中文参考文档
api手册地址:http://www.matools.com/api/redis

Ruby
api手册地址:http://www.matools.com/api/ruby

Ruby-library
api手册地址:http://www.matools.com/api/ruby-library

Ruby on Rails
api手册地址:http://www.matools.com/api/rubyonrails

Shiro
api手册地址:http://www.matools.com/api/shiro

Spring最新版
api手册地址:http://www.matools.com/api/spring

Spring for Android
api手册地址:http://www.matools.com/api/spring-android

Spring Boot
api手册地址:http://www.matools.com/api/spring-boot

Spring Cloud中文文档
api手册地址:http://www.matools.com/api/spring-cloud

Spring Security
api手册地址:http://www.matools.com/api/spring-security

Spring中文版
api手册地址:http://www.matools.com/api/spring-zh

Struts 2最新版
api手册地址:http://www.matools.com/api/struts2

Taperstry
api手册地址:http://www.matools.com/api/taperstry

TensorFlow中文
api手册地址:http://www.matools.com/api/tensorflow

Tomcat
api手册地址:http://www.matools.com/api/tomcat

Ubuntu
api手册地址:http://www.matools.com/api/ubuntu

Velocity 1.7
api手册地址:http://www.matools.com/api/velocity

VelocityTools2.0
api手册地址:http://www.matools.com/api/velocity-tools

Vue Router中文参考
api手册地址:http://www.matools.com/api/vue-router

vue.js中文文档
api手册地址:http://www.matools.com/api/vuejs

XMLBeans
api手册地址:http://www.matools.com/api/xmlbeans

Yahoo UI中文版
api手册地址:http://www.matools.com/api/yui

Zend Framework中文版
api手册地址:http://www.matools.com/api/zend-framework

Zookeeper
api手册地址:http://www.matools.com/api/zookeeper

⑽ 如何优雅的“编写”api接口文档

1. 拼写要准确
接口函数一旦发布就不能改了,要保持兼容性,拼写错误也不能改了,所以要仔细检查拼写,否则会被同行嘲笑很多年。
着名悲剧:unix 的 creat

2. 不仅是英文单词不要拼错,时态也不要错。
比如:
返回bool的判断函数,单数要用 is 复数要用are,这样你的命名就和文档中的描述保持了一致性。
表示状态的变量或者函数要注意时态,比如 onXxxxChanged 表示xxx已经变化了,isConnecting表示正在连接。
正确的时态可以给使用者传递更丰富的信息。

3. 函数最好是动宾结构
动宾结构就是 doSomething,这样的函数命名含义明确
比如: openFile, allocBuffer, setName
如果这个函数的动词宾语就是这个对象本身,那么可以省略掉宾语

4. 属性命名最好是定语+名词
比如 fileName, maxSize, textColor

5. 不要用生僻单词,这不是秀英语的地方,也不要用汉语拼音
比如:rendezvous,估计大多数人要去查词典才知道什么意思,这个词源自法语,是约会的意思。
Symbian OS里有个用它命名的函数,开发Symbian的是英国人,也许人家觉得很平常吧,反正我是查了词典才知道的。

6. 不要自己发明缩写
除非是约定俗成已经被广泛使用的缩写,否则老老实实用完整拼写。
坏例子: count->cnt, manager->mngr password->pw button->btn
现代的IDE都有很好的自动完成功能,名字长一点没关系的,可读性更重要。

7. 保持方法的对称性,有些方法一旦出现就应该是成对的,
比如 有open就要有close,有alloc就要有free,有add就要有remove,这些单词基本是固定搭配的,使用者就很容易理解。
如果 open对应clear就有点让人困惑了。

阅读全文

与api在线文档源码相关的资料

热点内容
如何做一个系统u盘文件夹名字 浏览:968
如何确认哪个ip重启了服务器 浏览:130
照片压缩软件绿色版 浏览:109
pgp基于什么体系加密 浏览:637
python合法赋值语句格式 浏览:713
程序员数学线性代数 浏览:624
看帧率app如何使用 浏览:525
从DHC服务器租用IP地址 浏览:477
编译怎么学 浏览:333
数码管显示0到9plc编程 浏览:667
服务器是为什么服务的 浏览:769
java定义数据类型 浏览:878
安卓pdf手写 浏览:431
什么是app开发者 浏览:288
android闹钟重启 浏览:105
程序员失职 浏览:522
在云服务器怎么改密码 浏览:588
服务器pb什么意思 浏览:944
51驾驶员的是什么app 浏览:674
php静态变量销毁 浏览:890