fix(firstleg): publish sailing edit and history paths
This commit is contained in:
@@ -29,17 +29,17 @@ paths:
|
||||
x-permission: platform:firstleg:sailing-calendar:list
|
||||
parameters: [{name: id, in: path, required: true, schema: {type: integer, format: int64}}]
|
||||
responses: {'200': {description: OK}}
|
||||
put:
|
||||
summary: 编辑船期
|
||||
x-permission: platform:firstleg:sailing-calendar:edit
|
||||
parameters: [{name: id, in: path, required: true, schema: {type: integer, format: int64}}]
|
||||
responses: {'200': {description: OK}}
|
||||
/api/platform/v1/sailings/{id}/history:
|
||||
get:
|
||||
summary: 查询船期变更历史
|
||||
x-permission: platform:firstleg:sailing-calendar:list
|
||||
parameters: [{name: id, in: path, required: true, schema: {type: integer, format: int64}}]
|
||||
responses: {'200': {description: OK}}
|
||||
put:
|
||||
summary: 编辑船期
|
||||
x-permission: platform:firstleg:sailing-calendar:edit
|
||||
parameters: [{name: id, in: path, required: true, schema: {type: integer, format: int64}}]
|
||||
responses: {'200': {description: OK}}
|
||||
/api/platform/v1/sailings/{id}/cancel:
|
||||
post:
|
||||
summary: 取消船期
|
||||
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
package com.baiyue.firstleg.sailingcalendar.controller;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.core.io.ClassPathResource;
|
||||
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
class SailingCalendarOpenApiContractTest {
|
||||
@Test
|
||||
void publishesEditAndHistoryOnTheControllerPaths() throws Exception {
|
||||
String yaml = new ClassPathResource("openapi/sailing-calendar-v1.yaml")
|
||||
.getContentAsString(StandardCharsets.UTF_8);
|
||||
String editPath = "/api/platform/v1/sailings/{id}:";
|
||||
String historyPath = "/api/platform/v1/sailings/{id}/history:";
|
||||
int editStart = yaml.indexOf(editPath);
|
||||
int historyStart = yaml.indexOf(historyPath);
|
||||
|
||||
assertThat(editStart).isGreaterThanOrEqualTo(0);
|
||||
assertThat(historyStart).isGreaterThan(editStart);
|
||||
String editBlock = yaml.substring(editStart, historyStart);
|
||||
String historyBlock = yaml.substring(historyStart);
|
||||
int nextPath = historyBlock.indexOf("\n /api/");
|
||||
if (nextPath >= 0) historyBlock = historyBlock.substring(0, nextPath);
|
||||
|
||||
assertThat(editBlock)
|
||||
.contains(" put:")
|
||||
.contains("x-permission: platform:firstleg:sailing-calendar:edit");
|
||||
assertThat(historyBlock)
|
||||
.contains(" get:")
|
||||
.contains("summary: 查询船期变更历史")
|
||||
.doesNotContain(" put:");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user