Skip to content

Commit

Permalink
修复BaseURL与接口相对路径问题
Browse files Browse the repository at this point in the history
  • Loading branch information
core-lib committed Aug 26, 2019
1 parent c79af0b commit 87b8cba
Show file tree
Hide file tree
Showing 24 changed files with 55 additions and 45 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HttpDoc [![](https://www.jitpack.io/v/core-lib/httpdoc.svg)](https://www.jitpack.io/#core-lib/httpdoc)
##### 基于Java标准doc注释构建的代码零侵入的HTTP RESTful API在线测试,文档阅览以及SDK导出框架,支持Spring-Boot和Spring-MVC
JSON-Editor: [httpdoc-ui](http://106.13.16.25:8080/httpdoc-sample-v1.7.8/httpdoc-ui/index.html) TextArea: [httpdoc-ui-v1](http://106.13.16.25:8080/httpdoc-sample-v1.7.8/httpdoc-ui-v1/index.html)
JSON-Editor: [httpdoc-ui](http://106.13.16.25:8080/httpdoc-sample-v1.7.9/httpdoc-ui/index.html) TextArea: [httpdoc-ui-v1](http://106.13.16.25:8080/httpdoc-sample-v1.7.9/httpdoc-ui-v1/index.html)

## 功能特性
* 基础功能无需为配合HttpDoc框架而多写一句代码,甚至连doc注释都不必写,即可拥有项目的API文档和测试界面。
Expand Down Expand Up @@ -31,7 +31,7 @@ JDK 1.7 +
<dependency>
<groupId>com.github.core-lib.httpdoc</groupId>
<artifactId>httpdoc-spring-mvc</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>

<!-- 添加JDK的tools.jar依赖用于解析源码注释,采用这种方式部署到Tomcat时需要往Tomcat的lib目录增加该tools.jar -->
Expand Down Expand Up @@ -131,7 +131,7 @@ JDK 1.7 +
<dependency>
<groupId>com.github.core-lib.httpdoc</groupId>
<artifactId>httpdoc-spring-boot</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>
```
```java
Expand Down Expand Up @@ -166,9 +166,11 @@ JDK 1.7 +
| serializer | 文档序列化器| JSON序列化器,所以项目中需要依赖jackson-databind |

## 在线示例
项目中的httpdoc-sample模块就是一个HttpDoc + SpringMVC的一个标准示例,可checkout后查看源码和编译运行查看效果,也可立即预览:JSON-Editor: [httpdoc-ui](http://106.13.16.25:8080/httpdoc-sample-v1.7.8/httpdoc-ui/index.html) TextArea: [httpdoc-ui-v1](http://106.13.16.25:8080/httpdoc-sample-v1.7.8/httpdoc-ui-v1/index.html)
项目中的httpdoc-sample模块就是一个HttpDoc + SpringMVC的一个标准示例,可checkout后查看源码和编译运行查看效果,也可立即预览:JSON-Editor: [httpdoc-ui](http://106.13.16.25:8080/httpdoc-sample-v1.7.9/httpdoc-ui/index.html) TextArea: [httpdoc-ui-v1](http://106.13.16.25:8080/httpdoc-sample-v1.7.9/httpdoc-ui-v1/index.html)

## 变更记录
* v1.7.9
* 修复BaseURL与接口相对路径问题
* v1.7.8
* UI 默认采用 grid 方式展示API参数
* v1.7.7
Expand Down
2 changes: 1 addition & 1 deletion httpdoc-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
4 changes: 2 additions & 2 deletions httpdoc-gson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>io.httpdoc</groupId>
<artifactId>httpdoc-core</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>
<dependency>
<groupId>com.google.code.gson</groupId>
Expand Down
4 changes: 2 additions & 2 deletions httpdoc-jackson/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -25,7 +25,7 @@
<dependency>
<groupId>io.httpdoc</groupId>
<artifactId>httpdoc-core</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
Expand Down
4 changes: 2 additions & 2 deletions httpdoc-jestful-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -28,7 +28,7 @@
<dependency>
<groupId>io.httpdoc</groupId>
<artifactId>httpdoc-core</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
<dependency>
<groupId>com.github.core-lib.httpdoc</groupId>
<artifactId>httpdoc-jestful-client</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.core-lib.httpdoc</groupId>
<artifactId>httpdoc-jackson</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions httpdoc-jestful-server/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -28,7 +28,7 @@
<dependency>
<groupId>io.httpdoc</groupId>
<artifactId>httpdoc-web</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>
<dependency>
<groupId>com.github.core-lib.jestful</groupId>
Expand Down
4 changes: 2 additions & 2 deletions httpdoc-nutz/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>io.httpdoc</groupId>
<artifactId>httpdoc-web</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>
<dependency>
<groupId>org.nutz</groupId>
Expand Down
4 changes: 2 additions & 2 deletions httpdoc-objc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>io.httpdoc</groupId>
<artifactId>httpdoc-core</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ protected Collection<ObjCSelectorFragment> generate(OperationGenerateContext con
selector.setResultFragment(call);
selector.setName(operation.getName());
Generation generation = context.getGeneration();
Document document = context.getDocument();
Controller controller = context.getController();
List<Parameter> parameters = operation.getParameters() != null ? operation.getParameters() : Collections.<Parameter>emptyList();
Collection<ObjCParameterFragment> fragments = generate(new ParameterGenerateContext(generation, controller, operation, parameters));
Expand Down Expand Up @@ -206,12 +205,15 @@ protected Collection<ObjCSelectorFragment> generate(OperationGenerateContext con
selector.getParameterFragments().add(success);

StringBuilder builder = new StringBuilder();
List<String> segments = Arrays.asList(document.getContext(), controller.getPath(), operation.getPath());
List<String> segments = Arrays.asList(controller.getPath(), operation.getPath());
for (String segment : segments) {
if (segment == null) continue;
builder.append("/").append(segment);
}
String uri = builder.toString().replaceAll("/+", "/");
while (uri.startsWith("/")) {
uri = uri.substring(1);
}
String method = operation.getMethod();

selector.addSentence("RSInvocation *invocation = [RSInvocation " + method.toUpperCase() + ":@\"" + uri + "\"];", RSInvocation.class);
Expand Down
4 changes: 2 additions & 2 deletions httpdoc-retrofit/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>io.httpdoc</groupId>
<artifactId>httpdoc-core</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,12 +203,15 @@ protected Collection<HDAnnotation> annotate(Document document, Controller contro
}

StringBuilder builder = new StringBuilder();
List<String> segments = Arrays.asList(document.getContext(), controller.getPath(), operation.getPath());
List<String> segments = Arrays.asList(controller.getPath(), operation.getPath());
for (String segment : segments) {
if (segment == null) continue;
builder.append("/").append(segment);
}
String path = builder.toString().replaceAll("/+", "/");
while (path.startsWith("/")) {
path = path.substring(1);
}

switch (operation.getMethod()) {
case "HEAD": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
<dependency>
<groupId>com.github.core-lib.httpdoc</groupId>
<artifactId>httpdoc-retrofit</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.core-lib.httpdoc</groupId>
<artifactId>httpdoc-jackson</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions httpdoc-retrofit2/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -21,7 +21,7 @@
<dependency>
<groupId>io.httpdoc</groupId>
<artifactId>httpdoc-core</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>

<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,12 +206,15 @@ protected Collection<HDAnnotation> annotate(Document document, Controller contro
}

StringBuilder builder = new StringBuilder();
List<String> segments = Arrays.asList(document.getContext(), controller.getPath(), operation.getPath());
List<String> segments = Arrays.asList(controller.getPath(), operation.getPath());
for (String segment : segments) {
if (segment == null) continue;
builder.append("/").append(segment);
}
String path = builder.toString().replaceAll("/+", "/");
while (path.startsWith("/")) {
path = path.substring(1);
}

switch (operation.getMethod()) {
case "HEAD": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@
<dependency>
<groupId>com.github.core-lib.httpdoc</groupId>
<artifactId>httpdoc-retrofit2</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>com.github.core-lib.httpdoc</groupId>
<artifactId>httpdoc-jackson</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
4 changes: 2 additions & 2 deletions httpdoc-sample/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -17,7 +17,7 @@
<properties>
<spring.version>4.3.9.RELEASE</spring.version>
<jackson.version>2.9.5</jackson.version>
<httpdoc.version>v1.7.8</httpdoc.version>
<httpdoc.version>v1.7.9</httpdoc.version>
</properties>

<dependencies>
Expand Down
4 changes: 2 additions & 2 deletions httpdoc-spring-boot/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down Expand Up @@ -33,7 +33,7 @@
<dependency>
<groupId>io.httpdoc</groupId>
<artifactId>httpdoc-spring-mvc</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>
</dependencies>

Expand Down
4 changes: 2 additions & 2 deletions httpdoc-spring-mvc/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand All @@ -26,7 +26,7 @@
<dependency>
<groupId>io.httpdoc</groupId>
<artifactId>httpdoc-web</artifactId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
Expand Down
2 changes: 1 addition & 1 deletion httpdoc-ui/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>httpdoc</artifactId>
<groupId>io.httpdoc</groupId>
<version>v1.7.8</version>
<version>v1.7.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="navbar-header">
<a class="navbar-brand" href="https://github.com/core-lib/httpdoc" target="_blank">
HttpDoc UI
<span class="badge">v1.7.8</span>
<span class="badge">v1.7.9</span>
</a>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="navbar-header">
<a class="navbar-brand" href="https://github.com/core-lib/httpdoc" target="_blank">
HttpDoc UI
<span class="badge">v1.7.8</span>
<span class="badge">v1.7.9</span>
</a>
</div>
</div>
Expand Down
Loading

0 comments on commit 87b8cba

Please sign in to comment.