@@ -17,6 +17,7 @@ import type {
1717} from 'payload'
1818import { entityToJSONSchema } from 'payload'
1919import type { SanitizedPluginOptions } from '../types.js'
20+ import { isHiddenField } from '../utils/fields.js'
2021import { mapValuesAsync , visitObjectNodes } from '../utils/objects.js'
2122import { type ComponentType , collectionName , componentName , globalName } from './naming.js'
2223import { apiKeySecurity , generateSecuritySchemes } from './securitySchemes.js'
@@ -96,6 +97,14 @@ const generateSchemaObject = (config: SanitizedConfig, collection: Collection):
9697 undefined ,
9798 )
9899
100+ schema . properties = Object . fromEntries (
101+ Object . entries ( schema . properties ?? { } ) . filter ( ( [ property ] ) => {
102+ const field = collection . config . fields . find ( field => ( field as FieldBase ) . name === property )
103+
104+ return ! isHiddenField ( field )
105+ } ) ,
106+ )
107+
99108 return {
100109 ...schema ,
101110 title : collectionName ( collection ) . singular ,
@@ -133,9 +142,12 @@ const generateRequestBodySchema = (
133142 )
134143
135144 schema . properties = Object . fromEntries (
136- Object . entries ( schema . properties ?? { } ) . filter (
137- ( [ property ] ) => ! [ 'id' , 'createdAt' , 'updatedAt' ] . includes ( property ) ,
138- ) ,
145+ Object . entries ( schema . properties ?? { } ) . filter ( ( [ property ] ) => {
146+ const field = collection . config . fields . find ( field => ( field as FieldBase ) . name === property )
147+ const isRequestBodyProperty = ! [ 'id' , 'createdAt' , 'updatedAt' ] . includes ( property )
148+
149+ return isRequestBodyProperty && ! isHiddenField ( field )
150+ } ) ,
139151 )
140152 schema . required = ( ( schema . required ?? [ ] ) as string [ ] ) . filter (
141153 property => schema . properties ?. [ property ] !== undefined ,
0 commit comments