Skip to content

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

Description

@cortinico

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    HacktoberfestIssues eligible for Hacktoberfest: https://hacktoberfest.digitalocean.com/detailsbugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions