Skip to content

Commit

Permalink
Add OpenApi 3.1 schema example. (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
cjbooms authored Feb 28, 2023
1 parent 3fd7de2 commit f0653a0
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@ class ModelGeneratorTest {
"validationAnnotations",
"wildCardTypes",
"singleAllOf",
"responsesSchema"
"responsesSchema",
"webhook",
)

@BeforeEach
Expand Down
34 changes: 34 additions & 0 deletions src/test/resources/examples/webhook/api.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
openapi: 3.1.0
info:
title: Webhook Example
version: 1.0.0
# Since OAS 3.1.0 the paths element isn't necessary. Now a valid OpenAPI Document can describe only paths, webhooks, or even only reusable components
webhooks:
# Each webhook needs a name
newPet:
# This is a Path Item Object, the only difference is that the request is initiated by the API provider
post:
requestBody:
description: Information about a new pet in the system
content:
application/json:
schema:
$ref: "#/components/schemas/Pet"
responses:
"200":
description: Return a 200 status to indicate that the data was received successfully

components:
schemas:
Pet:
required:
- id
- name
properties:
id:
type: integer
format: int64
name:
type: string
tag:
type: string
20 changes: 20 additions & 0 deletions src/test/resources/examples/webhook/models/Models.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package examples.webhook.models

import com.fasterxml.jackson.annotation.JsonProperty
import javax.validation.constraints.NotNull
import kotlin.Long
import kotlin.String

data class Pet(
@param:JsonProperty("id")
@get:JsonProperty("id")
@get:NotNull
val id: Long,
@param:JsonProperty("name")
@get:JsonProperty("name")
@get:NotNull
val name: String,
@param:JsonProperty("tag")
@get:JsonProperty("tag")
val tag: String? = null
)

0 comments on commit f0653a0

Please sign in to comment.