Skip to content

Commit 64bb8e3

Browse files
committed
request body test case
1 parent f5e46ad commit 64bb8e3

4 files changed

Lines changed: 82 additions & 1 deletion

File tree

src/testInt/groovy/com/github/hauner/openapi/generatr/GeneratrPendingTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class GeneratrPendingTest extends GeneratrTestBase {
2727
@Parameterized.Parameters(name = "{0}")
2828
static Collection<TestSet> sources () {
2929
return [
30-
new TestSet(name: 'path-params-simple-data-types')
30+
new TestSet(name: 'params-request-body')
3131
]
3232
}
3333

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* This class is auto generated by https://github.com/hauner/openapi-generatr-spring.
3+
* DO NOT EDIT.
4+
*/
5+
6+
package generated.api;
7+
8+
import generated.model.Book;
9+
import org.springframework.http.ResponseEntity;
10+
import org.springframework.web.bind.annotation.PostMapping;
11+
12+
public interface Api {
13+
14+
@PostMapping(path = "/book", consumes = {"application/json"}, produces = {"application/json"})
15+
ResponseEntity<Book> postBook(@RequestBody Book body);
16+
17+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* This class is auto generated by https://github.com/hauner/openapi-generatr-spring.
3+
* DO NOT EDIT.
4+
*/
5+
6+
package generated.model;
7+
8+
import com.fasterxml.jackson.annotation.JsonProperty;
9+
10+
public class Book {
11+
12+
@JsonProperty("isbn")
13+
private String isbn;
14+
15+
@JsonProperty("title")
16+
private String title;
17+
18+
public String getIsbn () {
19+
return isbn;
20+
}
21+
22+
public void setIsbn (String isbn) {
23+
this.isbn = isbn;
24+
}
25+
26+
public String getTitle () {
27+
return title;
28+
}
29+
30+
public void setTitle (String title) {
31+
this.title = title;
32+
}
33+
34+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
openapi: 3.0.2
2+
info:
3+
title: test request body parameters
4+
version: 1.0.0
5+
6+
paths:
7+
/book:
8+
post:
9+
requestBody:
10+
content:
11+
application/json:
12+
schema:
13+
$ref: '#/components/schemas/Book'
14+
responses:
15+
'201':
16+
description: created book
17+
content:
18+
application/json:
19+
schema:
20+
$ref: '#/components/schemas/Book'
21+
22+
components:
23+
schemas:
24+
Book:
25+
type: object
26+
properties:
27+
isbn:
28+
type: string
29+
title:
30+
type: string

0 commit comments

Comments
 (0)