Skip to content

Commit 488f9cc

Browse files
authored
Make content fields required in post and content models (#7972)
#### What type of PR is this? /area core /kind improvement /milestone 2.22.x #### What this PR does / why we need it: See #7967 #### Which issue(s) this PR fixes: Fixes #7967 #### Does this PR introduce a user-facing change? ```release-note None ```
1 parent 9d85275 commit 488f9cc

File tree

12 files changed

+65
-38
lines changed

12 files changed

+65
-38
lines changed

api-docs/openapi/v3_0/aggregated.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16932,6 +16932,11 @@
1693216932
}
1693316933
},
1693416934
"Content": {
16935+
"required": [
16936+
"content",
16937+
"raw",
16938+
"rawType"
16939+
],
1693516940
"type": "object",
1693616941
"properties": {
1693716942
"content": {
@@ -16946,6 +16951,11 @@
1694616951
}
1694716952
},
1694816953
"ContentUpdateParam": {
16954+
"required": [
16955+
"content",
16956+
"raw",
16957+
"rawType"
16958+
],
1694916959
"type": "object",
1695016960
"properties": {
1695116961
"content": {
@@ -17473,6 +17483,7 @@
1747317483
"type": "object",
1747417484
"properties": {
1747517485
"email": {
17486+
"minLength": 1,
1747617487
"type": "string"
1747717488
}
1747817489
}
@@ -20475,6 +20486,7 @@
2047520486
},
2047620487
"PostRequest": {
2047720488
"required": [
20489+
"content",
2047820490
"post"
2047920491
],
2048020492
"type": "object",
@@ -20580,12 +20592,12 @@
2058020592
},
2058120593
"visible": {
2058220594
"type": "string",
20583-
"default": "PUBLIC",
2058420595
"enum": [
2058520596
"PUBLIC",
2058620597
"INTERNAL",
2058720598
"PRIVATE"
20588-
]
20599+
],
20600+
"default": "PUBLIC"
2058920601
}
2059020602
}
2059120603
},
@@ -22356,12 +22368,12 @@
2235622368
},
2235722369
"visible": {
2235822370
"type": "string",
22359-
"default": "PUBLIC",
2236022371
"enum": [
2236122372
"PUBLIC",
2236222373
"INTERNAL",
2236322374
"PRIVATE"
22364-
]
22375+
],
22376+
"default": "PUBLIC"
2236522377
}
2236622378
}
2236722379
},

api-docs/openapi/v3_0/apis_console.api_v1alpha1.json

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4074,6 +4074,11 @@
40744074
}
40754075
},
40764076
"Content": {
4077+
"required": [
4078+
"content",
4079+
"raw",
4080+
"rawType"
4081+
],
40774082
"type": "object",
40784083
"properties": {
40794084
"content": {
@@ -4088,6 +4093,11 @@
40884093
}
40894094
},
40904095
"ContentUpdateParam": {
4096+
"required": [
4097+
"content",
4098+
"raw",
4099+
"rawType"
4100+
],
40914101
"type": "object",
40924102
"properties": {
40934103
"content": {
@@ -4317,6 +4327,7 @@
43174327
"type": "object",
43184328
"properties": {
43194329
"email": {
4330+
"minLength": 1,
43204331
"type": "string"
43214332
}
43224333
}
@@ -5343,6 +5354,7 @@
53435354
},
53445355
"PostRequest": {
53455356
"required": [
5357+
"content",
53465358
"post"
53475359
],
53485360
"type": "object",
@@ -5448,12 +5460,12 @@
54485460
},
54495461
"visible": {
54505462
"type": "string",
5451-
"default": "PUBLIC",
54525463
"enum": [
54535464
"PUBLIC",
54545465
"INTERNAL",
54555466
"PRIVATE"
5456-
]
5467+
],
5468+
"default": "PUBLIC"
54575469
}
54585470
}
54595471
},
@@ -5988,12 +6000,12 @@
59886000
},
59896001
"visible": {
59906002
"type": "string",
5991-
"default": "PUBLIC",
59926003
"enum": [
59936004
"PUBLIC",
59946005
"INTERNAL",
59956006
"PRIVATE"
5996-
]
6007+
],
6008+
"default": "PUBLIC"
59976009
}
59986010
}
59996011
},

api-docs/openapi/v3_0/apis_extension.api_v1alpha1.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12876,12 +12876,12 @@
1287612876
},
1287712877
"visible": {
1287812878
"type": "string",
12879-
"default": "PUBLIC",
1288012879
"enum": [
1288112880
"PUBLIC",
1288212881
"INTERNAL",
1288312882
"PRIVATE"
12884-
]
12883+
],
12884+
"default": "PUBLIC"
1288512885
}
1288612886
}
1288712887
},
@@ -14254,12 +14254,12 @@
1425414254
},
1425514255
"visible": {
1425614256
"type": "string",
14257-
"default": "PUBLIC",
1425814257
"enum": [
1425914258
"PUBLIC",
1426014259
"INTERNAL",
1426114260
"PRIVATE"
14262-
]
14261+
],
14262+
"default": "PUBLIC"
1426314263
}
1426414264
}
1426514265
},

api-docs/openapi/v3_0/apis_public.api_v1alpha1.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2633,12 +2633,12 @@
26332633
},
26342634
"visible": {
26352635
"type": "string",
2636-
"default": "PUBLIC",
26372636
"enum": [
26382637
"PUBLIC",
26392638
"INTERNAL",
26402639
"PRIVATE"
2641-
]
2640+
],
2641+
"default": "PUBLIC"
26422642
}
26432643
}
26442644
},
@@ -3211,12 +3211,12 @@
32113211
},
32123212
"visible": {
32133213
"type": "string",
3214-
"default": "PUBLIC",
32153214
"enum": [
32163215
"PUBLIC",
32173216
"INTERNAL",
32183217
"PRIVATE"
3219-
]
3218+
],
3219+
"default": "PUBLIC"
32203220
}
32213221
}
32223222
},

api-docs/openapi/v3_0/apis_uc.api_v1alpha1.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2470,12 +2470,12 @@
24702470
},
24712471
"visible": {
24722472
"type": "string",
2473-
"default": "PUBLIC",
24742473
"enum": [
24752474
"PUBLIC",
24762475
"INTERNAL",
24772476
"PRIVATE"
2478-
]
2477+
],
2478+
"default": "PUBLIC"
24792479
}
24802480
}
24812481
},
Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,10 @@
11
package run.halo.app.content;
22

3-
public record Content(String raw, String content, String rawType) {
3+
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
4+
5+
import io.swagger.v3.oas.annotations.media.Schema;
6+
7+
public record Content(@Schema(requiredMode = REQUIRED) String raw,
8+
@Schema(requiredMode = REQUIRED) String content,
9+
@Schema(requiredMode = REQUIRED) String rawType) {
410
}

application/src/main/java/run/halo/app/content/ContentUpdateParam.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package run.halo.app.content;
22

3-
public record ContentUpdateParam(Long version, String raw, String content, String rawType) {
3+
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
4+
5+
import io.swagger.v3.oas.annotations.media.Schema;
6+
7+
public record ContentUpdateParam(Long version, @Schema(requiredMode = REQUIRED) String raw,
8+
@Schema(requiredMode = REQUIRED) String content,
9+
@Schema(requiredMode = REQUIRED) String rawType) {
410

511
public static ContentUpdateParam from(Content content) {
612
return new ContentUpdateParam(null, content.raw(), content.content(),

application/src/main/java/run/halo/app/content/PostRequest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
* @since 2.0.0
1515
*/
1616
public record PostRequest(@Schema(requiredMode = REQUIRED) @NonNull Post post,
17-
ContentUpdateParam content) {
17+
@Schema(requiredMode = REQUIRED) @NonNull ContentUpdateParam content) {
1818

1919
public ContentRequest contentRequest() {
2020
Ref subjectRef = Ref.of(post);

ui/console-src/modules/contents/posts/PostEditor.vue

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,17 +78,8 @@ const handleChangeEditorProvider = async (provider: EditorProvider) => {
7878
}
7979
};
8080
81-
// fixme: PostRequest type may be wrong
82-
interface PostRequestWithContent extends PostRequest {
83-
content: {
84-
raw: string;
85-
content: string;
86-
rawType: string;
87-
};
88-
}
89-
9081
// Post form
91-
const formState = ref<PostRequestWithContent>({
82+
const formState = ref<PostRequest>({
9283
post: {
9384
spec: {
9485
title: "",

ui/packages/api-client/src/models/content-update-param.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616

1717
export interface ContentUpdateParam {
18-
'content'?: string;
19-
'raw'?: string;
20-
'rawType'?: string;
18+
'content': string;
19+
'raw': string;
20+
'rawType': string;
2121
'version'?: number;
2222
}
2323

0 commit comments

Comments
 (0)