-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OpenAPI 3.1.0 Add webhooks support (#17174)
* Add support for webhooks * Test webhook generation with Go Gin server * Generate samples * Removing \t * Remove tabs
- Loading branch information
Showing
10 changed files
with
363 additions
and
14 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
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
255 changes: 246 additions & 9 deletions
255
modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java
Large diffs are not rendered by default.
Oops, something went wrong.
24 changes: 24 additions & 0 deletions
24
modules/openapi-generator/src/main/java/org/openapitools/codegen/model/WebhooksMap.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,24 @@ | ||
package org.openapitools.codegen.model; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class WebhooksMap extends HashMap<String, Object> { | ||
public OperationMap getWebhooks() { | ||
return (OperationMap) get("operations"); | ||
} | ||
|
||
public void setWebhooks(OperationMap objs) { | ||
put("operations", objs); | ||
} | ||
|
||
@SuppressWarnings("unchecked") | ||
public List<Map<String, String>> getImports() { | ||
return (List<Map<String, String>>) get("imports"); | ||
} | ||
|
||
public void setImports(List<Map<String, String>> imports) { | ||
put("imports", imports); | ||
} | ||
} |
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
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
34 changes: 34 additions & 0 deletions
34
modules/openapi-generator/src/test/resources/3_1/webhooks.yaml
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 @@ | ||
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 |
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