@@ -43,21 +43,21 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get
4343
4444-- uses a reference for the 200 HTTP code response
4545select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'responses'->'200');
46- jsonb_pretty
47- ----------------------------------------------------
48- { +
49- "$ref": "#/components/responses/get .products",+
50- "description": "OK" +
46+ jsonb_pretty
47+ ---------------------------------------------------------
48+ { +
49+ "$ref": "#/components/responses/notEmpty .products",+
50+ "description": "OK" +
5151 }
5252(1 row)
5353
5454-- uses a reference for the 206 HTTP code response
5555select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'get'->'responses'->'206');
56- jsonb_pretty
57- ----------------------------------------------------
58- { +
59- "$ref": "#/components/responses/get .products",+
60- "description": "Partial Content" +
56+ jsonb_pretty
57+ ---------------------------------------------------------
58+ { +
59+ "$ref": "#/components/responses/notEmpty .products",+
60+ "description": "Partial Content" +
6161 }
6262(1 row)
6363
@@ -115,11 +115,11 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'pos
115115
116116-- uses a reference for the 201 HTTP code response
117117select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'post'->'responses'->'201');
118- jsonb_pretty
119- -----------------------------------------------------
120- { +
121- "$ref": "#/components/responses/post .products",+
122- "description": "Created" +
118+ jsonb_pretty
119+ -----------------------------------------------------------
120+ { +
121+ "$ref": "#/components/responses/mayBeEmpty .products",+
122+ "description": "Created" +
123123 }
124124(1 row)
125125
@@ -151,6 +151,77 @@ where value->>'$ref' like '#/components/parameters/%';
151151 {"$ref": "#/components/parameters/preferPost"}
152152(3 rows)
153153
154+ -- PATCH operation object
155+ -- shows the table name as tag
156+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'tags');
157+ jsonb_pretty
158+ ----------------
159+ [ +
160+ "products"+
161+ ]
162+ (1 row)
163+
164+ -- uses a reference for the 200 HTTP code response
165+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'responses'->'200');
166+ jsonb_pretty
167+ ---------------------------------------------------------
168+ { +
169+ "$ref": "#/components/responses/notEmpty.products",+
170+ "description": "OK" +
171+ }
172+ (1 row)
173+
174+ -- uses a reference for the 204 HTTP code response
175+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'responses'->'204');
176+ jsonb_pretty
177+ ---------------------------------------------
178+ { +
179+ "$ref": "#/components/responses/empty",+
180+ "description": "No Content" +
181+ }
182+ (1 row)
183+
184+ -- uses a reference for error responses
185+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'responses'->'default');
186+ jsonb_pretty
187+ ----------------------------------------------------
188+ { +
189+ "$ref": "#/components/responses/defaultError",+
190+ "description": "Error" +
191+ }
192+ (1 row)
193+
194+ -- uses references for columns as query parameters
195+ select value
196+ from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'parameters')
197+ where value->>'$ref' like '#/components/parameters/rowFilter.products.%';
198+ value
199+ --------------------------------------------------------------------
200+ {"$ref": "#/components/parameters/rowFilter.products.id"}
201+ {"$ref": "#/components/parameters/rowFilter.products.code"}
202+ {"$ref": "#/components/parameters/rowFilter.products.name"}
203+ {"$ref": "#/components/parameters/rowFilter.products.description"}
204+ {"$ref": "#/components/parameters/rowFilter.products.attr"}
205+ {"$ref": "#/components/parameters/rowFilter.products.size"}
206+ (6 rows)
207+
208+ -- uses references for common parameters
209+ select value
210+ from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/products'->'patch'->'parameters')
211+ where value->>'$ref' not like '#/components/parameters/rowFilter.products.%';
212+ value
213+ -------------------------------------------------
214+ {"$ref": "#/components/parameters/select"}
215+ {"$ref": "#/components/parameters/columns"}
216+ {"$ref": "#/components/parameters/order"}
217+ {"$ref": "#/components/parameters/limit"}
218+ {"$ref": "#/components/parameters/or"}
219+ {"$ref": "#/components/parameters/and"}
220+ {"$ref": "#/components/parameters/not.or"}
221+ {"$ref": "#/components/parameters/not.and"}
222+ {"$ref": "#/components/parameters/preferPatch"}
223+ (9 rows)
224+
154225-- Views
155226-- GET operation object
156227-- shows the table name as tag
@@ -165,21 +236,21 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->
165236
166237-- uses a reference for the 200 HTTP code response
167238select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'responses'->'200');
168- jsonb_pretty
169- --------------------------------------------------------
170- { +
171- "$ref": "#/components/responses/get .big_products",+
172- "description": "OK" +
239+ jsonb_pretty
240+ -------------------------------------------------------------
241+ { +
242+ "$ref": "#/components/responses/notEmpty .big_products",+
243+ "description": "OK" +
173244 }
174245(1 row)
175246
176247-- uses a reference for the 206 HTTP code response
177248select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'get'->'responses'->'206');
178- jsonb_pretty
179- --------------------------------------------------------
180- { +
181- "$ref": "#/components/responses/get .big_products",+
182- "description": "Partial Content" +
249+ jsonb_pretty
250+ -------------------------------------------------------------
251+ { +
252+ "$ref": "#/components/responses/notEmpty .big_products",+
253+ "description": "Partial Content" +
183254 }
184255(1 row)
185256
@@ -242,11 +313,11 @@ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->
242313
243314-- uses a reference for the 201 HTTP code response
244315select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'post'->'responses'->'201');
245- jsonb_pretty
246- ---------------------------------------------------------
247- { +
248- "$ref": "#/components/responses/post .big_products",+
249- "description": "Created" +
316+ jsonb_pretty
317+ ---------------------------------------------------------------
318+ { +
319+ "$ref": "#/components/responses/mayBeEmpty .big_products",+
320+ "description": "Created" +
250321 }
251322(1 row)
252323
@@ -285,3 +356,79 @@ select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'post'
285356 f
286357(1 row)
287358
359+ -- PATCH operation object
360+ -- shows the table name as tag
361+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'tags');
362+ jsonb_pretty
363+ --------------------
364+ [ +
365+ "big_products"+
366+ ]
367+ (1 row)
368+
369+ -- uses a reference for the 200 HTTP code response
370+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'responses'->'200');
371+ jsonb_pretty
372+ -------------------------------------------------------------
373+ { +
374+ "$ref": "#/components/responses/notEmpty.big_products",+
375+ "description": "OK" +
376+ }
377+ (1 row)
378+
379+ -- uses a reference for the 204 HTTP code response
380+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'responses'->'204');
381+ jsonb_pretty
382+ ---------------------------------------------
383+ { +
384+ "$ref": "#/components/responses/empty",+
385+ "description": "No Content" +
386+ }
387+ (1 row)
388+
389+ -- uses a reference for error responses
390+ select jsonb_pretty(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'responses'->'default');
391+ jsonb_pretty
392+ ----------------------------------------------------
393+ { +
394+ "$ref": "#/components/responses/defaultError",+
395+ "description": "Error" +
396+ }
397+ (1 row)
398+
399+ -- uses references for columns as query parameters
400+ select value
401+ from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'parameters')
402+ where value->>'$ref' like '#/components/parameters/rowFilter.big_products.%';
403+ value
404+ -----------------------------------------------------------------
405+ {"$ref": "#/components/parameters/rowFilter.big_products.id"}
406+ {"$ref": "#/components/parameters/rowFilter.big_products.code"}
407+ {"$ref": "#/components/parameters/rowFilter.big_products.name"}
408+ {"$ref": "#/components/parameters/rowFilter.big_products.size"}
409+ (4 rows)
410+
411+ -- uses references for common parameters
412+ select value
413+ from jsonb_array_elements(postgrest_openapi_spec('{test}')->'paths'->'/big_products'->'patch'->'parameters')
414+ where value->>'$ref' not like '#/components/parameters/rowFilter.big_products.%';
415+ value
416+ -------------------------------------------------
417+ {"$ref": "#/components/parameters/select"}
418+ {"$ref": "#/components/parameters/columns"}
419+ {"$ref": "#/components/parameters/order"}
420+ {"$ref": "#/components/parameters/limit"}
421+ {"$ref": "#/components/parameters/or"}
422+ {"$ref": "#/components/parameters/and"}
423+ {"$ref": "#/components/parameters/not.or"}
424+ {"$ref": "#/components/parameters/not.and"}
425+ {"$ref": "#/components/parameters/preferPatch"}
426+ (9 rows)
427+
428+ -- does not show a PATCH operation object for non auto-updatable views
429+ select postgrest_openapi_spec('{test}')->'paths'->'/non_auto_updatable' ? 'patch' as value;
430+ value
431+ -------
432+ f
433+ (1 row)
434+
0 commit comments