fix(firstleg): publish sailing edit and history paths

This commit is contained in:
2026-09-27 19:20:10 +08:00
parent cdff6ba69d
commit 4777f29c5b
2 changed files with 40 additions and 5 deletions
@@ -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: 取消船期
@@ -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:");
}
}