Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1814 from okohub/feature-get-with-body
Allow requestBody creation for GET on openapi resource endpoint
- Loading branch information
Showing
6 changed files
with
208 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
springdoc-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app6/DummyData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* | ||
* * | ||
* * * | ||
* * * * Copyright 2019-2022 the original author or authors. | ||
* * * * | ||
* * * * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * * * you may not use this file except in compliance with the License. | ||
* * * * You may obtain a copy of the License at | ||
* * * * | ||
* * * * https://www.apache.org/licenses/LICENSE-2.0 | ||
* * * * | ||
* * * * Unless required by applicable law or agreed to in writing, software | ||
* * * * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * * * See the License for the specific language governing permissions and | ||
* * * * limitations under the License. | ||
* * * | ||
* * | ||
* | ||
*/ | ||
|
||
package test.org.springdoc.api.v31.app6; | ||
|
||
import java.time.Instant; | ||
|
||
public class DummyData { | ||
|
||
String trackerId; | ||
|
||
Instant timestamp; | ||
|
||
Double value; | ||
|
||
public String getTrackerId() { | ||
return trackerId; | ||
} | ||
|
||
public void setTrackerId(String trackerId) { | ||
this.trackerId = trackerId; | ||
} | ||
|
||
public Instant getTimestamp() { | ||
return timestamp; | ||
} | ||
|
||
public void setTimestamp(Instant timestamp) { | ||
this.timestamp = timestamp; | ||
} | ||
|
||
public Double getValue() { | ||
return value; | ||
} | ||
|
||
public void setValue(Double value) { | ||
this.value = value; | ||
} | ||
} |
39 changes: 39 additions & 0 deletions
39
...-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app6/GetBodyController.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
/* | ||
* | ||
* * | ||
* * * | ||
* * * * Copyright 2019-2022 the original author or authors. | ||
* * * * | ||
* * * * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * * * you may not use this file except in compliance with the License. | ||
* * * * You may obtain a copy of the License at | ||
* * * * | ||
* * * * https://www.apache.org/licenses/LICENSE-2.0 | ||
* * * * | ||
* * * * Unless required by applicable law or agreed to in writing, software | ||
* * * * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * * * See the License for the specific language governing permissions and | ||
* * * * limitations under the License. | ||
* * * | ||
* * | ||
* | ||
*/ | ||
|
||
package test.org.springdoc.api.v31.app6; | ||
|
||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RestController; | ||
import test.org.springdoc.api.v31.app4.TrackerData; | ||
|
||
@RestController | ||
public class GetBodyController { | ||
|
||
@GetMapping(value = "/get/body") | ||
DummyData getBody(@RequestBody DummyData dummyData) { | ||
return dummyData; | ||
|
||
} | ||
|
||
} |
34 changes: 34 additions & 0 deletions
34
...-openapi-webmvc-core/src/test/java/test/org/springdoc/api/v31/app6/SpringDocApp6Test.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* | ||
* * | ||
* * * | ||
* * * * Copyright 2019-2022 the original author or authors. | ||
* * * * | ||
* * * * Licensed under the Apache License, Version 2.0 (the "License"); | ||
* * * * you may not use this file except in compliance with the License. | ||
* * * * You may obtain a copy of the License at | ||
* * * * | ||
* * * * https://www.apache.org/licenses/LICENSE-2.0 | ||
* * * * | ||
* * * * Unless required by applicable law or agreed to in writing, software | ||
* * * * distributed under the License is distributed on an "AS IS" BASIS, | ||
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* * * * See the License for the specific language governing permissions and | ||
* * * * limitations under the License. | ||
* * * | ||
* * | ||
* | ||
*/ | ||
|
||
package test.org.springdoc.api.v31.app6; | ||
|
||
import org.springframework.boot.autoconfigure.SpringBootApplication; | ||
import test.org.springdoc.api.v31.AbstractSpringDocV31Test; | ||
|
||
public class SpringDocApp6Test extends AbstractSpringDocV31Test { | ||
|
||
@SpringBootApplication | ||
static class SpringDocTestApp { | ||
|
||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
springdoc-openapi-webmvc-core/src/test/resources/results/3.1.0/app6.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
{ | ||
"openapi": "3.1.0", | ||
"info": { | ||
"title": "OpenAPI definition", | ||
"version": "v0" | ||
}, | ||
"servers": [ | ||
{ | ||
"url": "http://localhost", | ||
"description": "Generated server url" | ||
} | ||
], | ||
"paths": { | ||
"/get/body": { | ||
"get": { | ||
"tags": [ | ||
"get-body-controller" | ||
], | ||
"operationId": "getBody", | ||
"requestBody": { | ||
"content": { | ||
"application/json": { | ||
"schema": { | ||
"$ref": "#/components/schemas/DummyData" | ||
} | ||
} | ||
}, | ||
"required": true | ||
}, | ||
"responses": { | ||
"200": { | ||
"description": "OK", | ||
"content": { | ||
"*/*": { | ||
"schema": { | ||
"$ref": "#/components/schemas/DummyData" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
}, | ||
"components": { | ||
"schemas": { | ||
"DummyData": { | ||
"properties": { | ||
"trackerId": { | ||
"type": "string" | ||
}, | ||
"timestamp": { | ||
"type": "string", | ||
"format": "date-time" | ||
}, | ||
"value": { | ||
"type": "number", | ||
"format": "double" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |