@@ -88,6 +88,8 @@ const genericObjectSchema: AnySchemaObject = {
8888} ;
8989
9090const errorResponseSchema : AnySchemaObject = {
91+ title : 'AdminForthErrorResponse' ,
92+ description : 'Standard error response returned by AdminForth endpoints.' ,
9193 type : 'object' ,
9294 required : [ 'error' ] ,
9395 properties : {
@@ -97,20 +99,25 @@ const errorResponseSchema: AnySchemaObject = {
9799} ;
98100
99101const recordIdentifierSchema : AnySchemaObject = {
102+ title : 'AdminForthRecordIdentifier' ,
103+ description : 'Record identifier accepted by AdminForth. Depending on the resource it can be a string or a number.' ,
100104 anyOf : [
101105 { type : 'string' } ,
102106 { type : 'number' } ,
103107 ] ,
104108} ;
105109
106110const actionIdentifierSchema : AnySchemaObject = {
111+ title : 'AdminForthActionIdentifier' ,
112+ description : 'Action identifier accepted by AdminForth. Depending on configuration it can be a string or a number.' ,
107113 anyOf : [
108114 { type : 'string' } ,
109115 { type : 'number' } ,
110116 ] ,
111117} ;
112118
113119const namedColumnSchema : AnySchemaObject = {
120+ title : 'AdminForthNamedColumn' ,
114121 type : 'object' ,
115122 required : [ 'name' ] ,
116123 properties : {
@@ -120,6 +127,7 @@ const namedColumnSchema: AnySchemaObject = {
120127} ;
121128
122129const validationResultSchema : AnySchemaObject = {
130+ title : 'AdminForthValidationResult' ,
123131 type : 'object' ,
124132 required : [ 'isValid' ] ,
125133 properties : {
@@ -129,56 +137,97 @@ const validationResultSchema: AnySchemaObject = {
129137 additionalProperties : true ,
130138} ;
131139
132- const commonFilterSchemaDefs : Record < string , AnySchemaObject > = {
133- singleFilter : {
134- type : 'object' ,
135- properties : {
136- field : { type : 'string' } ,
137- operator : { type : 'string' , enum : SIMPLE_FILTER_OPERATORS } ,
138- value : { } ,
139- rightField : { type : 'string' } ,
140- insecureRawSQL : { type : 'string' } ,
141- insecureRawNoSQL : { } ,
140+ const filterConditionExample = {
141+ field : 'status' ,
142+ operator : AdminForthFilterOperators . EQ ,
143+ value : 'active' ,
144+ } ;
145+
146+ const filterGroupExample = {
147+ operator : AdminForthFilterOperators . AND ,
148+ subFilters : [ filterConditionExample ] ,
149+ } ;
150+
151+ const sortItemExample = {
152+ field : 'createdAt' ,
153+ direction : AdminForthSortDirections . desc ,
154+ } ;
155+
156+ const filterConditionSchema : AnySchemaObject = {
157+ title : 'AdminForthFilterCondition' ,
158+ description : 'Single field comparison used in AdminForth filtering.' ,
159+ type : 'object' ,
160+ properties : {
161+ field : { type : 'string' } ,
162+ operator : { type : 'string' , enum : SIMPLE_FILTER_OPERATORS } ,
163+ value : { } ,
164+ rightField : { type : 'string' } ,
165+ insecureRawSQL : { type : 'string' } ,
166+ insecureRawNoSQL : { } ,
167+ } ,
168+ additionalProperties : true ,
169+ examples : [ filterConditionExample ] ,
170+ } ;
171+
172+ const filterGroupSchema : AnySchemaObject = {
173+ title : 'AdminForthFilterGroup' ,
174+ description : 'Nested boolean filter group. Use this for AND or OR combinations of filter nodes.' ,
175+ type : 'object' ,
176+ required : [ 'operator' , 'subFilters' ] ,
177+ properties : {
178+ operator : {
179+ type : 'string' ,
180+ enum : [ AdminForthFilterOperators . AND , AdminForthFilterOperators . OR ] ,
181+ } ,
182+ subFilters : {
183+ type : 'array' ,
184+ items : { $ref : '#/$defs/filterNode' } ,
185+ description : 'Nested filters evaluated with the selected operator.' ,
142186 } ,
143- additionalProperties : true ,
144187 } ,
188+ additionalProperties : true ,
189+ examples : [ filterGroupExample ] ,
190+ } ;
191+
192+ const sortItemSchema : AnySchemaObject = {
193+ title : 'AdminForthSortItem' ,
194+ description : 'Single sort instruction applied in order with the rest of the list.' ,
195+ type : 'object' ,
196+ required : [ 'field' , 'direction' ] ,
197+ properties : {
198+ field : { type : 'string' } ,
199+ direction : { type : 'string' , enum : Object . values ( AdminForthSortDirections ) } ,
200+ } ,
201+ additionalProperties : true ,
202+ examples : [ sortItemExample ] ,
203+ } ;
204+
205+ const commonFilterSchemaDefs : Record < string , AnySchemaObject > = {
206+ singleFilter : filterConditionSchema ,
207+ filterGroup : filterGroupSchema ,
145208 filterNode : {
209+ title : 'AdminForthFilterNode' ,
210+ description : 'Either a single filter condition or a nested filter group.' ,
146211 anyOf : [
147212 { $ref : '#/$defs/singleFilter' } ,
148- {
149- type : 'object' ,
150- required : [ 'operator' , 'subFilters' ] ,
151- properties : {
152- operator : {
153- type : 'string' ,
154- enum : [ AdminForthFilterOperators . AND , AdminForthFilterOperators . OR ] ,
155- } ,
156- subFilters : {
157- type : 'array' ,
158- items : { $ref : '#/$defs/filterNode' } ,
159- } ,
160- } ,
161- additionalProperties : true ,
162- } ,
213+ { $ref : '#/$defs/filterGroup' } ,
163214 ] ,
215+ examples : [ filterConditionExample , filterGroupExample ] ,
164216 } ,
165- sortItem : {
166- type : 'object' ,
167- required : [ 'field' , 'direction' ] ,
168- properties : {
169- field : { type : 'string' } ,
170- direction : { type : 'string' , enum : Object . values ( AdminForthSortDirections ) } ,
171- } ,
172- additionalProperties : true ,
173- } ,
217+ sortItem : sortItemSchema ,
174218} ;
175219
176220const commonSortSchema : AnySchemaObject = {
221+ title : 'AdminForthSortList' ,
222+ description : 'Ordered list of sort instructions.' ,
177223 type : 'array' ,
178224 items : { $ref : '#/$defs/sortItem' } ,
225+ examples : [ [ sortItemExample ] ] ,
179226} ;
180227
181228const commonFiltersSchema : AnySchemaObject = {
229+ title : 'AdminForthFilterInput' ,
230+ description : 'Runtime accepts either a single filter node or an array of filter nodes. The OpenAPI document normalizes this to the array form for readability.' ,
182231 oneOf : [
183232 {
184233 type : 'array' ,
@@ -203,9 +252,19 @@ const getResourceDataRequestSchema: AnySchemaObject = {
203252 required : [ 'resourceId' , 'source' , 'limit' , 'offset' , 'filters' , 'sort' ] ,
204253 properties : {
205254 resourceId : { type : 'string' } ,
206- source : { type : 'string' , enum : [ 'show' , 'list' , 'edit' ] } ,
207- limit : { type : 'integer' } ,
208- offset : { type : 'integer' } ,
255+ source : {
256+ type : 'string' ,
257+ enum : [ 'show' , 'list' , 'edit' ] ,
258+ description : 'Target UI context. Show and edit requests should use direct field filters that identify a single record.' ,
259+ } ,
260+ limit : {
261+ type : 'integer' ,
262+ description : 'Maximum number of rows to return for the current page.' ,
263+ } ,
264+ offset : {
265+ type : 'integer' ,
266+ description : 'Zero-based row offset used for pagination.' ,
267+ } ,
209268 sort : commonSortSchema ,
210269 filters : commonFiltersSchema ,
211270 } ,
@@ -287,8 +346,14 @@ const getResourceForeignDataRequestSchema: AnySchemaObject = {
287346 properties : {
288347 resourceId : { type : 'string' } ,
289348 column : { type : 'string' } ,
290- limit : { type : 'integer' } ,
291- offset : { type : 'integer' } ,
349+ limit : {
350+ type : 'integer' ,
351+ description : 'Maximum number of dropdown options to return.' ,
352+ } ,
353+ offset : {
354+ type : 'integer' ,
355+ description : 'Zero-based offset used to fetch the next option page.' ,
356+ } ,
292357 search : { type : 'string' } ,
293358 filters : commonFiltersSchema ,
294359 sort : commonSortSchema ,
0 commit comments