Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin is failing with endpoints and inlined parameters + additionalProperties #70

Open
cortinico opened this issue Sep 20, 2019 · 0 comments
Labels
bug Something isn't working Hacktoberfest Issues eligible for Hacktoberfest: https://hacktoberfest.digitalocean.com/details

Comments

@cortinico
Copy link
Collaborator

Just got a bug report on Slack for swagger-gradle-codegen (credits to @vanniktech). After some small investigation with @macisamuele looks like the issue is with paths that have parameters with inlined additional properties.

Here a minimal spec that is breaking the plugin:

{
  "swagger": "2.0",
  "info": {
    "version": "1.0",
    "title": ""
  },
  "definitions": {
    "model": {
      "type": "object",
      "additionalProperties": {
        "type": "string"
      }
    }
  },
  "paths": {
    "/works": {
      "post": {
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "schema": {
              "$ref" : "#/definitions/model"
            }
          }
        ],
        "responses": {
          "default": {
            "description": "something"
          }
        }
      }
    },
    "/broken": {
      "post": {
        "parameters": [
          {
            "in": "body",
            "name": "body",
            "schema": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            }
          }
        ],
        "responses": {
          "default": {
            "description": "something"
          }
        }
      }
    }
  }
}

The current workaround is to replace this:

         {
            "in": "body",
            "name": "body",
            "schema": {
              "type": "object",
              "additionalProperties": {
                "type": "string"
              }
            }
          }

with:

          {
            "in": "body",
            "name": "body",
            "schema": {
              "$ref" : "#/definitions/model"
            }
          }

And have the additionalProperties not defined inline.

Here the failure message:

Execution failed for task ':generateSwagger'.
> Could not process operation:
    Tag: Tag {
  	name: default
  	description: null
  	externalDocs: null
  	extensions:{}}
    Operation: null
    Resource: post /broken
    Definitions: {model=io.swagger.models.ModelImpl@a2a8ef}
    Exception: null cannot be cast to non-null type io.swagger.models.ModelImpl
@cortinico cortinico added the bug Something isn't working label Sep 20, 2019
@cortinico cortinico added the Hacktoberfest Issues eligible for Hacktoberfest: https://hacktoberfest.digitalocean.com/details label Oct 2, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working Hacktoberfest Issues eligible for Hacktoberfest: https://hacktoberfest.digitalocean.com/details
Projects
None yet
Development

No branches or pull requests

1 participant