mirror of
https://github.com/valitydev/openapi-generator.git
synced 2024-11-07 02:55:19 +00:00
Add a test case for inline models within Callback Object (#3665)
This commit is contained in:
parent
8c498fb08a
commit
6addd76e11
@ -804,4 +804,42 @@ public class InlineModelResolverTest {
|
||||
Schema nullableRequestBodySchema = ModelUtils.getReferencedSchema(openAPI, nullableRequestBodyReference);
|
||||
assertTrue(nullableRequestBodySchema.getNullable());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void callbacks() {
|
||||
OpenAPI openAPI = TestUtils.parseSpec("src/test/resources/3_0/inline_model_resolver.yaml");
|
||||
new InlineModelResolver().flatten(openAPI);
|
||||
|
||||
RequestBody callbackRequestBodyReference = openAPI
|
||||
.getPaths()
|
||||
.get("/callback")
|
||||
.getPost()
|
||||
.getCallbacks()
|
||||
.get("webhook")
|
||||
.get("{$request.body#/callbackUri}")
|
||||
.getPost()
|
||||
.getRequestBody();
|
||||
assertNotNull(callbackRequestBodyReference.get$ref());
|
||||
|
||||
RequestBody resolvedCallbackRequestBody = openAPI
|
||||
.getComponents()
|
||||
.getRequestBodies()
|
||||
.get(ModelUtils.getSimpleRef(callbackRequestBodyReference.get$ref()));
|
||||
|
||||
Schema callbackRequestSchemaReference = resolvedCallbackRequestBody
|
||||
.getContent()
|
||||
.get("application/json")
|
||||
.getSchema();
|
||||
assertNotNull(callbackRequestSchemaReference.get$ref());
|
||||
|
||||
Schema resolvedCallbackSchema = openAPI
|
||||
.getComponents()
|
||||
.getSchemas()
|
||||
.get(ModelUtils.getSimpleRef(callbackRequestSchemaReference.get$ref()));
|
||||
|
||||
Map properties = resolvedCallbackSchema.getProperties();
|
||||
assertTrue(properties.get("notificationId") instanceof StringSchema);
|
||||
assertTrue(properties.get("action") instanceof StringSchema);
|
||||
assertTrue(properties.get("data") instanceof StringSchema);
|
||||
}
|
||||
}
|
@ -293,6 +293,40 @@ paths:
|
||||
responses:
|
||||
'200':
|
||||
description: OK
|
||||
/callback:
|
||||
post:
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
callbackUri:
|
||||
type: string
|
||||
responses:
|
||||
201:
|
||||
headers:
|
||||
Location:
|
||||
description: Contains the URI of the newly created resource
|
||||
schema:
|
||||
type: string
|
||||
callbacks:
|
||||
webhook:
|
||||
'{$request.body#/callbackUri}':
|
||||
post:
|
||||
operationId: webhookNotify
|
||||
requestBody:
|
||||
content:
|
||||
application/json:
|
||||
schema:
|
||||
type: object
|
||||
properties:
|
||||
notificationId:
|
||||
type: string
|
||||
action:
|
||||
type: string
|
||||
data:
|
||||
type: string
|
||||
components:
|
||||
schemas:
|
||||
Users:
|
||||
|
Loading…
Reference in New Issue
Block a user