Skip to content

openAPI v3 - Callbacks feature #372

@CyrilleBenard

Description

@CyrilleBenard
Description

New feature :

I was wondering when the callbacks feature (openAPI v3) will be planned to be developed in the openapi-generator ?
The 2 "languages" I'm interesting in are :
C++ (cpp-pistache-server and cpp-restsdk)
Java (jaxrs-resteasy)

Below a small openapi file useful to check this feature

openapi-generator version

N/A

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  version: 1.0.0
  title: Simple Callback example
  description: Validate a simple callback
paths:
  /subscribe:
    post:
      summary: Subscribe to a notification
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                callbackUrl: 
                  type: string
                  format: uri
                  example: http://client_domain/the_call_back_endpoint
              required:
                - callbackUrl
      responses:
        '201':
          description: Subscription created
        '403':
          description: Forbidden

      callbacks: 
        onEventReport: 
          '{$request.body#/callbackUrl}': 
            post:
              requestBody:
                required: true
                content:
                  application/json:
                    schema:
                      type: object
                      properties:
                        message:
                          type: string
                          example: Event 01 raised
                      required:
                        - message
              responses: # Expected responses (from the client) to the callback message
                '204':
                  description: Successful acknowledgement
                default:
                  description: Unexpected error
{
  "openapi": "3.0.0",
  "info": {
    "version": "1.0.0",
    "title": "Simple Callback example",
    "description": "Validate a simple callback"
  },
  "paths": {
    "/subscribe": {
      "post": {
        "summary": "Subscribe to a notification",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "callbackUrl": {
                    "type": "string",
                    "format": "uri",
                    "example": "http://client_domain/the_call_back_endpoint"
                  }
                },
                "required": [
                  "callbackUrl"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Subscription created"
          },
          "403": {
            "description": "Forbidden"
          }
        },
        "callbacks": {
          "onEventReport": {
            "{$request.body#/callbackUrl}": {
              "post": {
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "type": "object",
                        "properties": {
                          "message": {
                            "type": "string",
                            "example": "Event 01 raised"
                          }
                        },
                        "required": [
                          "message"
                        ]
                      }
                    }
                  }
                },
                "responses": {
                  "204": {
                    "description": "Successful acknowledgement"
                  },
                  "default": {
                    "description": "Unexpected error"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}
Command line used for generation

N/A

Steps to reproduce

N/A

Related issues/PRs

N/A

Suggest a fix/enhancement

N/A

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions