Skip to content

Commit

Permalink
fix: 预处理 JSONSchema 时仅将 object 的 additionalProperties 属性设置为 false
Browse files Browse the repository at this point in the history
  • Loading branch information
fjc0k committed Jun 4, 2021
1 parent 6a4e7c7 commit 2b5e25a
Show file tree
Hide file tree
Showing 2 changed files with 136 additions and 190 deletions.
6 changes: 4 additions & 2 deletions src/utils.ts
Expand Up @@ -68,8 +68,10 @@ export function processJsonSchema<T extends JSONSchema4>(jsonSchema: T): T {
delete jsonSchema.minItems
delete jsonSchema.maxItems

// 将 additionalProperties 设为 false
jsonSchema.additionalProperties = false
if (jsonSchema.type === 'object') {
// 将 additionalProperties 设为 false
jsonSchema.additionalProperties = false
}

// 删除通过 swagger 导入时未剔除的 ref
delete jsonSchema.$ref
Expand Down

0 comments on commit 2b5e25a

Please sign in to comment.