BAEL-3896: OpenAPI JSON Objects in Query Params - README file revert + required changes

This commit is contained in:
alex.peptan 2020-05-23 20:06:43 +03:00
parent 5b0097f698
commit 59afec1c00
3 changed files with 179 additions and 130 deletions

View File

@ -13,4 +13,3 @@ The "REST With Spring" Classes: http://bit.ly/restwithspring
- [Spring RequestMapping](https://www.baeldung.com/spring-requestmapping) - [Spring RequestMapping](https://www.baeldung.com/spring-requestmapping)
- [Guide to DeferredResult in Spring](https://www.baeldung.com/spring-deferred-result) - [Guide to DeferredResult in Spring](https://www.baeldung.com/spring-deferred-result)
- [Using JSON Patch in Spring REST APIs](https://www.baeldung.com/spring-rest-json-patch) - [Using JSON Patch in Spring REST APIs](https://www.baeldung.com/spring-rest-json-patch)
- [OpenAPI JSON Objects in Query Params](https://www.baeldung.com/openapi-json-objects-in-query-params)

View File

@ -0,0 +1,32 @@
swagger: '3.0'
info:
title: Sample API to send JSON objects as query parameters using OpenAPI 3
description: API description.
version: 1.0.0
paths:
/tickets:
get:
parameters:
- in: query
name: params
required: true
# Parameter is an object that should be serialized as JSON
content:
application/json:
schema:
type: object
properties:
type:
type: string
name:
color: string
responses:
'200':
description: successful process
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found

View File

@ -1,5 +1,9 @@
swagger: '2.0' swagger: '2.0'
... info:
title: Sample API to send JSON objects as query parameters using OpenAPI 2
description: API description.
version: 1.0.0
paths: paths:
/tickets: /tickets:
get: get:
@ -10,10 +14,16 @@ paths:
description: A JSON object with the `type` and `color` properties description: A JSON object with the `type` and `color` properties
type: string type: string
example: '{"type":"foo","color":"green"}' example: '{"type":"foo","color":"green"}'
responses:
'200':
description: successful process
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
swagger: '2.0'
...
paths:
/tickets: /tickets:
post: post:
requestBody: requestBody:
@ -26,129 +36,137 @@ paths:
responses: responses:
'200': '200':
description: successful process description: successful process
'201':
description: Created
'401':
description: Unauthorized
'403':
description: Forbidden
'404':
description: Not Found
"/api/tickets": { /api/tickets: {
"get": { get: {
"tags": [ tags: [
"account-resource" "account-resource"
], ],
"summary": "testQueryParamApi", summary: "testQueryParamApi",
"operationId": "testQueryParamApiUsingGET", operationId: "testQueryParamApiUsingGET",
"produces": [ produces: [
"*/*" "*/*"
], ],
"parameters": [ parameters: [
{ {
"name": "params", name: "params",
"in": "query", in: "query",
"description": "params", description: "params",
"required": true, required: true,
"type": "string" type: "string"
} }
], ],
"responses": { responses: {
"200": { 200: {
"description": "OK", description: "OK",
"schema": { schema: {
"type": "string" type: "string"
} }
}, },
"401": { 401: {
"description": "Unauthorized" description: "Unauthorized"
}, },
"403": { 403: {
"description": "Forbidden" description: "Forbidden"
}, },
"404": { 404: {
"description": "Not Found" description: "Not Found"
} }
}, },
"deprecated": false deprecated: false
}, },
"post": { post: {
"tags": [ tags: [
"account-resource" "account-resource"
], ],
"summary": "testBodyParamApi", summary: "testBodyParamApi",
"operationId": "testBodyParamApiUsingPOST", operationId: "testBodyParamApiUsingPOST",
"consumes": [ consumes: [
"application/json" "application/json"
], ],
"produces": [ produces: [
"*/*" "*/*"
], ],
"parameters": [ parameters: [
{ {
"in": "body", in: "body",
"name": "params", name: "params",
"description": "params", description: "params",
"required": true, required: true,
"schema": { schema: {
"type": "string" type: "string"
} }
} }
], ],
"responses": { responses: {
"200": { 200: {
"description": "OK", description: "OK",
"schema": { schema: {
"type": "string" type: "string"
} }
}, },
"201": { 201: {
"description": "Created" description: "Created"
}, },
"401": { 401: {
"description": "Unauthorized" description: "Unauthorized"
}, },
"403": { 403: {
"description": "Forbidden" description: "Forbidden"
}, },
"404": { 404: {
"description": "Not Found" description: "Not Found"
} }
}, },
"deprecated": false deprecated: false
} }
}, },
"/api/tickets2": { /api/tickets2: {
"get": { get: {
"tags": [ tags: [
"account-resource" "account-resource"
], ],
"summary": "testGetBodyParamApi", summary: "testGetBodyParamApi",
"operationId": "testGetBodyParamApiUsingGET", operationId: "testGetBodyParamApiUsingGET",
"produces": [ produces: [
"*/*" "*/*"
], ],
"parameters": [ parameters: [
{ {
"in": "body", in: "body",
"name": "params", name: "params",
"description": "params", description: "params",
"required": true, required: true,
"schema": { schema: {
"type": "string" type: "string"
} }
} }
], ],
"responses": { responses: {
"200": { 200: {
"description": "OK", description: "OK",
"schema": { schema: {
"type": "string" type: "string"
} }
}, },
"401": { 401: {
"description": "Unauthorized" description: "Unauthorized"
}, },
"403": { 403: {
"description": "Forbidden" description: "Forbidden"
}, },
"404": { 404: {
"description": "Not Found" description: "Not Found"
} }
}, },
"deprecated": false deprecated: false
} }
} }