@@ -191,6 +191,13 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'pat
191191 }
192192(1 row)
193193
194+ -- uses a reference for request body
195+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'requestBody'->'$ref');
196+ jsonb_pretty
197+ ---------------------------------------
198+ "#/components/requestBodies/products"
199+ (1 row)
200+
194201-- uses references for columns as query parameters
195202select value
196203from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'parameters')
@@ -222,6 +229,76 @@ where value->>'$ref' not like '#/components/parameters/rowFilter.products.%';
222229 {"$ref": "#/components/parameters/preferPatch"}
223230(9 rows)
224231
232+ -- DELETE operation object
233+ -- shows the table name as tag
234+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'tags');
235+ jsonb_pretty
236+ ----------------
237+ [ +
238+ "products"+
239+ ]
240+ (1 row)
241+
242+ -- uses a reference for the 200 HTTP code response
243+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'responses'->'200');
244+ jsonb_pretty
245+ ---------------------------------------------------------
246+ { +
247+ "$ref": "#/components/responses/notEmpty.products",+
248+ "description": "OK" +
249+ }
250+ (1 row)
251+
252+ -- uses a reference for the 204 HTTP code response
253+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'responses'->'204');
254+ jsonb_pretty
255+ ---------------------------------------------
256+ { +
257+ "$ref": "#/components/responses/empty",+
258+ "description": "No Content" +
259+ }
260+ (1 row)
261+
262+ -- uses a reference for error responses
263+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'responses'->'default');
264+ jsonb_pretty
265+ ----------------------------------------------------
266+ { +
267+ "$ref": "#/components/responses/defaultError",+
268+ "description": "Error" +
269+ }
270+ (1 row)
271+
272+ -- uses references for columns as query parameters
273+ select value
274+ from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'parameters')
275+ where value->>'$ref' like '#/components/parameters/rowFilter.products.%';
276+ value
277+ --------------------------------------------------------------------
278+ {"$ref": "#/components/parameters/rowFilter.products.id"}
279+ {"$ref": "#/components/parameters/rowFilter.products.code"}
280+ {"$ref": "#/components/parameters/rowFilter.products.name"}
281+ {"$ref": "#/components/parameters/rowFilter.products.description"}
282+ {"$ref": "#/components/parameters/rowFilter.products.attr"}
283+ {"$ref": "#/components/parameters/rowFilter.products.size"}
284+ (6 rows)
285+
286+ -- uses references for common parameters
287+ select value
288+ from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'delete'->'parameters')
289+ where value->>'$ref' not like '#/components/parameters/rowFilter.products.%';
290+ value
291+ --------------------------------------------------
292+ {"$ref": "#/components/parameters/select"}
293+ {"$ref": "#/components/parameters/order"}
294+ {"$ref": "#/components/parameters/limit"}
295+ {"$ref": "#/components/parameters/or"}
296+ {"$ref": "#/components/parameters/and"}
297+ {"$ref": "#/components/parameters/not.or"}
298+ {"$ref": "#/components/parameters/not.and"}
299+ {"$ref": "#/components/parameters/preferDelete"}
300+ (8 rows)
301+
225302-- Views
226303-- GET operation object
227304-- shows the table name as tag
@@ -396,6 +473,13 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->
396473 }
397474(1 row)
398475
476+ -- uses a reference for request body
477+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'requestBody'->'$ref');
478+ jsonb_pretty
479+ -------------------------------------------
480+ "#/components/requestBodies/big_products"
481+ (1 row)
482+
399483-- uses references for columns as query parameters
400484select value
401485from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'parameters')
@@ -432,3 +516,78 @@ select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'patch
432516 f
433517(1 row)
434518
519+ -- DELETE operation object
520+ -- shows the table name as tag
521+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'tags');
522+ jsonb_pretty
523+ --------------------
524+ [ +
525+ "big_products"+
526+ ]
527+ (1 row)
528+
529+ -- uses a reference for the 200 HTTP code response
530+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'responses'->'200');
531+ jsonb_pretty
532+ -------------------------------------------------------------
533+ { +
534+ "$ref": "#/components/responses/notEmpty.big_products",+
535+ "description": "OK" +
536+ }
537+ (1 row)
538+
539+ -- uses a reference for the 204 HTTP code response
540+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'responses'->'204');
541+ jsonb_pretty
542+ ---------------------------------------------
543+ { +
544+ "$ref": "#/components/responses/empty",+
545+ "description": "No Content" +
546+ }
547+ (1 row)
548+
549+ -- uses a reference for error responses
550+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'responses'->'default');
551+ jsonb_pretty
552+ ----------------------------------------------------
553+ { +
554+ "$ref": "#/components/responses/defaultError",+
555+ "description": "Error" +
556+ }
557+ (1 row)
558+
559+ -- uses references for columns as query parameters
560+ select value
561+ from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'parameters')
562+ where value->>'$ref' like '#/components/parameters/rowFilter.big_products.%';
563+ value
564+ -----------------------------------------------------------------
565+ {"$ref": "#/components/parameters/rowFilter.big_products.id"}
566+ {"$ref": "#/components/parameters/rowFilter.big_products.code"}
567+ {"$ref": "#/components/parameters/rowFilter.big_products.name"}
568+ {"$ref": "#/components/parameters/rowFilter.big_products.size"}
569+ (4 rows)
570+
571+ -- uses references for common parameters
572+ select value
573+ from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'delete'->'parameters')
574+ where value->>'$ref' not like '#/components/parameters/rowFilter.big_products.%';
575+ value
576+ --------------------------------------------------
577+ {"$ref": "#/components/parameters/select"}
578+ {"$ref": "#/components/parameters/order"}
579+ {"$ref": "#/components/parameters/limit"}
580+ {"$ref": "#/components/parameters/or"}
581+ {"$ref": "#/components/parameters/and"}
582+ {"$ref": "#/components/parameters/not.or"}
583+ {"$ref": "#/components/parameters/not.and"}
584+ {"$ref": "#/components/parameters/preferDelete"}
585+ (8 rows)
586+
587+ -- does not show a DELETE operation object for non auto-updatable views
588+ select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'delete' as value;
589+ value
590+ -------
591+ f
592+ (1 row)
593+
0 commit comments