@@ -28,29 +28,38 @@ export const operationPagination = ({
28
28
context : IR . Context ;
29
29
operation : IR . OperationObject ;
30
30
} ) : Pagination | undefined => {
31
- if ( operation . body ?. pagination ) {
32
- if ( typeof operation . body . pagination === 'boolean' ) {
33
- return {
34
- in : 'body' ,
35
- name : 'body' ,
36
- schema : operation . body . schema ,
37
- } ;
38
- }
31
+ const body = operation . body ;
32
+
33
+ if ( ! body || ! body . pagination ) {
34
+ return parameterWithPagination ( operation . parameters ) ;
35
+ }
39
36
40
- const schema = operation . body . schema . $ref
41
- ? context . resolveIrRef < IR . RequestBodyObject | IR . SchemaObject > (
42
- operation . body . schema . $ref ,
43
- )
44
- : operation . body . schema ;
45
- const finalSchema = 'schema' in schema ? schema . schema : schema ;
37
+ if ( body . pagination === true ) {
46
38
return {
47
39
in : 'body' ,
48
- name : operation . body . pagination ,
49
- schema : finalSchema . properties ! [ operation . body . pagination ] ! ,
40
+ name : ' body' ,
41
+ schema : body . schema ,
50
42
} ;
51
43
}
52
44
53
- return parameterWithPagination ( operation . parameters ) ;
45
+ const schema = body . schema ;
46
+ const resolvedSchema = schema . $ref
47
+ ? context . resolveIrRef < IR . RequestBodyObject | IR . SchemaObject > ( schema . $ref )
48
+ : schema ;
49
+
50
+ const finalSchema =
51
+ 'schema' in resolvedSchema ? resolvedSchema . schema : resolvedSchema ;
52
+ const paginationProp = finalSchema ?. properties ?. [ body . pagination ] ;
53
+
54
+ if ( ! paginationProp ) {
55
+ return parameterWithPagination ( operation . parameters ) ;
56
+ }
57
+
58
+ return {
59
+ in : 'body' ,
60
+ name : body . pagination ,
61
+ schema : paginationProp ,
62
+ } ;
54
63
} ;
55
64
56
65
type StatusGroup = '1XX' | '2XX' | '3XX' | '4XX' | '5XX' | 'default' ;
0 commit comments