mirror of
https://github.com/halo-dev/halo.git
synced 2025-12-14 16:24:01 +08:00
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 ```
This commit is contained in:
@@ -16932,6 +16932,11 @@
|
||||
}
|
||||
},
|
||||
"Content": {
|
||||
"required": [
|
||||
"content",
|
||||
"raw",
|
||||
"rawType"
|
||||
],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
@@ -16946,6 +16951,11 @@
|
||||
}
|
||||
},
|
||||
"ContentUpdateParam": {
|
||||
"required": [
|
||||
"content",
|
||||
"raw",
|
||||
"rawType"
|
||||
],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
@@ -17473,6 +17483,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"minLength": 1,
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
@@ -20475,6 +20486,7 @@
|
||||
},
|
||||
"PostRequest": {
|
||||
"required": [
|
||||
"content",
|
||||
"post"
|
||||
],
|
||||
"type": "object",
|
||||
@@ -20580,12 +20592,12 @@
|
||||
},
|
||||
"visible": {
|
||||
"type": "string",
|
||||
"default": "PUBLIC",
|
||||
"enum": [
|
||||
"PUBLIC",
|
||||
"INTERNAL",
|
||||
"PRIVATE"
|
||||
]
|
||||
],
|
||||
"default": "PUBLIC"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -22356,12 +22368,12 @@
|
||||
},
|
||||
"visible": {
|
||||
"type": "string",
|
||||
"default": "PUBLIC",
|
||||
"enum": [
|
||||
"PUBLIC",
|
||||
"INTERNAL",
|
||||
"PRIVATE"
|
||||
]
|
||||
],
|
||||
"default": "PUBLIC"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -4074,6 +4074,11 @@
|
||||
}
|
||||
},
|
||||
"Content": {
|
||||
"required": [
|
||||
"content",
|
||||
"raw",
|
||||
"rawType"
|
||||
],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
@@ -4088,6 +4093,11 @@
|
||||
}
|
||||
},
|
||||
"ContentUpdateParam": {
|
||||
"required": [
|
||||
"content",
|
||||
"raw",
|
||||
"rawType"
|
||||
],
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"content": {
|
||||
@@ -4317,6 +4327,7 @@
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"email": {
|
||||
"minLength": 1,
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
@@ -5343,6 +5354,7 @@
|
||||
},
|
||||
"PostRequest": {
|
||||
"required": [
|
||||
"content",
|
||||
"post"
|
||||
],
|
||||
"type": "object",
|
||||
@@ -5448,12 +5460,12 @@
|
||||
},
|
||||
"visible": {
|
||||
"type": "string",
|
||||
"default": "PUBLIC",
|
||||
"enum": [
|
||||
"PUBLIC",
|
||||
"INTERNAL",
|
||||
"PRIVATE"
|
||||
]
|
||||
],
|
||||
"default": "PUBLIC"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -5988,12 +6000,12 @@
|
||||
},
|
||||
"visible": {
|
||||
"type": "string",
|
||||
"default": "PUBLIC",
|
||||
"enum": [
|
||||
"PUBLIC",
|
||||
"INTERNAL",
|
||||
"PRIVATE"
|
||||
]
|
||||
],
|
||||
"default": "PUBLIC"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -12876,12 +12876,12 @@
|
||||
},
|
||||
"visible": {
|
||||
"type": "string",
|
||||
"default": "PUBLIC",
|
||||
"enum": [
|
||||
"PUBLIC",
|
||||
"INTERNAL",
|
||||
"PRIVATE"
|
||||
]
|
||||
],
|
||||
"default": "PUBLIC"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -14254,12 +14254,12 @@
|
||||
},
|
||||
"visible": {
|
||||
"type": "string",
|
||||
"default": "PUBLIC",
|
||||
"enum": [
|
||||
"PUBLIC",
|
||||
"INTERNAL",
|
||||
"PRIVATE"
|
||||
]
|
||||
],
|
||||
"default": "PUBLIC"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2633,12 +2633,12 @@
|
||||
},
|
||||
"visible": {
|
||||
"type": "string",
|
||||
"default": "PUBLIC",
|
||||
"enum": [
|
||||
"PUBLIC",
|
||||
"INTERNAL",
|
||||
"PRIVATE"
|
||||
]
|
||||
],
|
||||
"default": "PUBLIC"
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -3211,12 +3211,12 @@
|
||||
},
|
||||
"visible": {
|
||||
"type": "string",
|
||||
"default": "PUBLIC",
|
||||
"enum": [
|
||||
"PUBLIC",
|
||||
"INTERNAL",
|
||||
"PRIVATE"
|
||||
]
|
||||
],
|
||||
"default": "PUBLIC"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -2470,12 +2470,12 @@
|
||||
},
|
||||
"visible": {
|
||||
"type": "string",
|
||||
"default": "PUBLIC",
|
||||
"enum": [
|
||||
"PUBLIC",
|
||||
"INTERNAL",
|
||||
"PRIVATE"
|
||||
]
|
||||
],
|
||||
"default": "PUBLIC"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
package run.halo.app.content;
|
||||
|
||||
public record Content(String raw, String content, String rawType) {
|
||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
public record Content(@Schema(requiredMode = REQUIRED) String raw,
|
||||
@Schema(requiredMode = REQUIRED) String content,
|
||||
@Schema(requiredMode = REQUIRED) String rawType) {
|
||||
}
|
||||
|
||||
@@ -1,6 +1,12 @@
|
||||
package run.halo.app.content;
|
||||
|
||||
public record ContentUpdateParam(Long version, String raw, String content, String rawType) {
|
||||
import static io.swagger.v3.oas.annotations.media.Schema.RequiredMode.REQUIRED;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
|
||||
public record ContentUpdateParam(Long version, @Schema(requiredMode = REQUIRED) String raw,
|
||||
@Schema(requiredMode = REQUIRED) String content,
|
||||
@Schema(requiredMode = REQUIRED) String rawType) {
|
||||
|
||||
public static ContentUpdateParam from(Content content) {
|
||||
return new ContentUpdateParam(null, content.raw(), content.content(),
|
||||
|
||||
@@ -14,7 +14,7 @@ import run.halo.app.extension.Ref;
|
||||
* @since 2.0.0
|
||||
*/
|
||||
public record PostRequest(@Schema(requiredMode = REQUIRED) @NonNull Post post,
|
||||
ContentUpdateParam content) {
|
||||
@Schema(requiredMode = REQUIRED) @NonNull ContentUpdateParam content) {
|
||||
|
||||
public ContentRequest contentRequest() {
|
||||
Ref subjectRef = Ref.of(post);
|
||||
|
||||
@@ -78,17 +78,8 @@ const handleChangeEditorProvider = async (provider: EditorProvider) => {
|
||||
}
|
||||
};
|
||||
|
||||
// fixme: PostRequest type may be wrong
|
||||
interface PostRequestWithContent extends PostRequest {
|
||||
content: {
|
||||
raw: string;
|
||||
content: string;
|
||||
rawType: string;
|
||||
};
|
||||
}
|
||||
|
||||
// Post form
|
||||
const formState = ref<PostRequestWithContent>({
|
||||
const formState = ref<PostRequest>({
|
||||
post: {
|
||||
spec: {
|
||||
title: "",
|
||||
|
||||
@@ -15,9 +15,9 @@
|
||||
|
||||
|
||||
export interface ContentUpdateParam {
|
||||
'content'?: string;
|
||||
'raw'?: string;
|
||||
'rawType'?: string;
|
||||
'content': string;
|
||||
'raw': string;
|
||||
'rawType': string;
|
||||
'version'?: number;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
|
||||
|
||||
export interface Content {
|
||||
'content'?: string;
|
||||
'raw'?: string;
|
||||
'rawType'?: string;
|
||||
'content': string;
|
||||
'raw': string;
|
||||
'rawType': string;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ import type { Post } from './post';
|
||||
* Post and content data for creating and updating post.
|
||||
*/
|
||||
export interface PostRequest {
|
||||
'content'?: ContentUpdateParam;
|
||||
'content': ContentUpdateParam;
|
||||
'post': Post;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user