swagger-api / swagger-api/swagger-parser

Problem with Callbacks having extensions

Open
#1,418 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Java
Stars
867
Forks
560
Avg merge
2d 21h
Merged PRs (30d)
7

Description

As per OpenAPI (Version: 3.0.3), Callback object (https://swagger.io/specification/#callback-object) May be extended with Specification Extensions (https://swagger.io/specification/#specification-extensions).

However the swagger-parser (2.0.17) fails to parse the following and throws “com.fasterxml.jackson.databind.node.TextNode cannot be cast to com.fasterxml.jackson.databind.node.ObjectNode”

{
  "openapi": "3.0.0",
  "info": {
    "version": "0.0.0",
    "title": "test"
  },
  "paths": {
    "/subscribe": {
      "post": {
        "summary": "Subscribe to a webhook",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "callbackUrl": {
                    "type": "string",
                    "format": "uri",
                    "example": "https://myserver.com/send/callback/here"
                  }
                },
                "required": [
                  "callbackUrl"
                ]
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Webhook created"
          }
        },
        "callbacks": {
          "myEvent": {
            "x-amazon-apigateway-authtype": "oauth2",
            "{$request.body#/callbackUrl}": {
              "post": {
                "requestBody": {
                  "required": true,
                  "content": {
                    "application/json": {
                      "schema": {
                        "type": "object",
                        "properties": {
                          "message": {
                            "type": "string",
                            "example": "Some event happened"
                          }
                        },
                        "required": [
                          "message"
                        ]
                      }
                    }
                  }
                },
                "responses": {
                  "200": {
                    "description": "Your server returns this code if it accepts the callback"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with the OpenAPI JSON included in the issue, then trace callback deserialization and how callback extensions are handled. Done means the provided document parses successfully without the TextNode/ObjectNode cast error and the callback extension remains supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.