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

[Swagger] ArrayIndexOutOfBoundsException with Swagger-codegen #454

Closed
georgeOsdDev opened this issue Aug 28, 2014 · 1 comment
Closed

[Swagger] ArrayIndexOutOfBoundsException with Swagger-codegen #454

georgeOsdDev opened this issue Aug 28, 2014 · 1 comment
Labels

Comments

@georgeOsdDev
Copy link
Member

./bin/runscala.sh com.wordnik.swagger.codegen.BasicScalaGenerator http://localhost:8000/xitrum/swagger                                                                             
base path is http://localhost:8000/xitrum/swagger
swagger version: 1.2
basePath:
api version: 1.0-SNAPSHOT
Aug 28, 2014 3:53:52 PM com.wordnik.swagger.codegen.spec.SwaggerSpecValidator validate
WARNING: no models found for listing  http://localhost:8000
Aug 28, 2014 3:53:52 PM com.wordnik.swagger.codegen.spec.SwaggerSpecValidator validate
WARNING: no models found for listing  http://localhost:8000
----------

java.lang.ArrayIndexOutOfBoundsException: 1
    at com.wordnik.swagger.codegen.PathUtil$class.resourceNameFromFullPath(PathUtil.scala:61)
    at com.wordnik.swagger.codegen.BasicGenerator.resourceNameFromFullPath(BasicGenerator.scala:39)
    at com.wordnik.swagger.codegen.BasicGenerator$$anonfun$groupOperationsToFiles$2.apply(BasicGenerator.scala:384)
    at com.wordnik.swagger.codegen.BasicGenerator$$anonfun$groupOperationsToFiles$2.apply(BasicGenerator.scala:383)
    at scala.collection.TraversableLike$WithFilter$$anonfun$foreach$1.apply(TraversableLike.scala:778)
    at scala.collection.immutable.List.foreach(List.scala:381)
    at scala.collection.TraversableLike$WithFilter.foreach(TraversableLike.scala:777)
    at com.wordnik.swagger.codegen.BasicGenerator.groupOperationsToFiles(BasicGenerator.scala:383)
    at com.wordnik.swagger.codegen.BasicGenerator.generate(BasicGenerator.scala:120)
    at com.wordnik.swagger.codegen.BasicGenerator.generateClientWithoutExit(BasicGenerator.scala:74)
    at com.wordnik.swagger.codegen.BasicGenerator.generateClient(BasicGenerator.scala:56)
    at com.wordnik.swagger.codegen.BasicScalaGenerator$.main(BasicScalaGenerator.scala:22)
    at com.wordnik.swagger.codegen.BasicScalaGenerator.main(BasicScalaGenerator.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at scala.reflect.internal.util.ScalaClassLoader$$anonfun$run$1.apply(ScalaClassLoader.scala:68)
    at scala.reflect.internal.util.ScalaClassLoader$class.asContext(ScalaClassLoader.scala:31)
    at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.asContext(ScalaClassLoader.scala:99)
    at scala.reflect.internal.util.ScalaClassLoader$class.run(ScalaClassLoader.scala:68)
    at scala.reflect.internal.util.ScalaClassLoader$URLClassLoader.run(ScalaClassLoader.scala:99)
    at scala.tools.nsc.CommonRunner$class.run(ObjectRunner.scala:22)
    at scala.tools.nsc.ObjectRunner$.run(ObjectRunner.scala:39)
    at scala.tools.nsc.CommonRunner$class.runAndCatch(ObjectRunner.scala:29)
    at scala.tools.nsc.ObjectRunner$.runAndCatch(ObjectRunner.scala:39)
    at scala.tools.nsc.MainGenericRunner.runTarget$1(MainGenericRunner.scala:65)
    at scala.tools.nsc.MainGenericRunner.run$1(MainGenericRunner.scala:87)
    at scala.tools.nsc.MainGenericRunner.process(MainGenericRunner.scala:98)
    at scala.tools.nsc.MainGenericRunner$.main(MainGenericRunner.scala:103)
    at scala.tools.nsc.MainGenericRunner.main(MainGenericRunner.scala)

This error happen with xitrum-framework/matsuri14@f127509 's demo project

Generated jsons

http://localhost:8000/xitrum/swagger

{
  "swaggerVersion" : "1.2",
  "apiVersion" : "1.0-SNAPSHOT",
  "apis" : [ {
    "path" : "/admin",
    "description" : "admin actions"
  }, {
    "path" : "/auth",
    "description" : "auth actions"
  } ]
}

http://localhost:8000/xitrum/swagger/admin

{
  "swaggerVersion" : "1.2",
  "apiVersion" : "1.0-SNAPSHOT",
  "basePath" : "http://localhost:8000",
  "resourcePath" : "/admin",
  "apis" : [ {
    "path" : "/admin",
    "operations" : [ {
      "httpMethod" : "GET",
      "summary" : "List Users",
      "notes" : "",
      "nickname" : "adminIndex",
      "type" : "string",
      "parameters" : [ {
        "name" : "format",
        "paramType" : "query",
        "type" : "string",
        "description" : "For API client: set `json`",
        "required" : false
      }, {
        "name" : "X-BasicAuthName",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user name",
        "required" : false
      }, {
        "name" : "X-BasicAuthPassword",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user password",
        "required" : false
      } ],
      "responseMessages" : [ {
        "code" : 401,
        "message" : "Unauthorized as admin user"
      }, {
        "code" : 200,
        "message" : "Return all users list"
      } ],
      "produces" : [ ],
      "consumes" : [ ]
    } ]
  }, {
    "path" : "/admin/msg/{name}",
    "operations" : [ {
      "httpMethod" : "GET",
      "summary" : "Return latest msg by name, result is from serverside-cache(not database)",
      "notes" : "",
      "nickname" : "adminUserMessages",
      "type" : "string",
      "parameters" : [ {
        "name" : "name",
        "paramType" : "path",
        "type" : "string",
        "description" : "",
        "required" : true
      }, {
        "name" : "format",
        "paramType" : "query",
        "type" : "string",
        "description" : "For API client: set `json`",
        "required" : false
      }, {
        "name" : "X-BasicAuthName",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user name",
        "required" : false
      }, {
        "name" : "X-BasicAuthPassword",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user password",
        "required" : false
      } ],
      "responseMessages" : [ {
        "code" : 401,
        "message" : "Unauthorized as admin user"
      }, {
        "code" : 200,
        "message" : "Response Msg"
      } ],
      "produces" : [ ],
      "consumes" : [ ]
    } ]
  }, {
    "path" : "/admin/user/{name}",
    "operations" : [ {
      "httpMethod" : "GET",
      "summary" : "Return specified user information",
      "notes" : "",
      "nickname" : "adminUserShow",
      "type" : "string",
      "parameters" : [ {
        "name" : "name",
        "paramType" : "path",
        "type" : "string",
        "description" : "",
        "required" : true
      }, {
        "name" : "format",
        "paramType" : "query",
        "type" : "string",
        "description" : "For API client: set `json`",
        "required" : false
      }, {
        "name" : "X-BasicAuthName",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user name",
        "required" : false
      }, {
        "name" : "X-BasicAuthPassword",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user password",
        "required" : false
      } ],
      "responseMessages" : [ {
        "code" : 401,
        "message" : "Unauthorized as admin user"
      }, {
        "code" : 200,
        "message" : "Response User"
      }, {
        "code" : 404,
        "message" : "No user found by specified name"
      } ],
      "produces" : [ ],
      "consumes" : [ ]
    } ]
  }, {
    "path" : "/admin/msg",
    "operations" : [ {
      "httpMethod" : "GET",
      "summary" : "Return latest msg, result is cached 1 minute",
      "notes" : "(Pction cache: 60 [sec])",
      "nickname" : "adminLastMessage",
      "type" : "string",
      "parameters" : [ {
        "name" : "format",
        "paramType" : "query",
        "type" : "string",
        "description" : "For API client: set `json`",
        "required" : false
      }, {
        "name" : "X-BasicAuthName",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user name",
        "required" : false
      }, {
        "name" : "X-BasicAuthPassword",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user password",
        "required" : false
      } ],
      "responseMessages" : [ {
        "code" : 401,
        "message" : "Unauthorized as admin user"
      }, {
        "code" : 200,
        "message" : "Response Msg"
      } ],
      "produces" : [ ],
      "consumes" : [ ]
    } ]
  }, {
    "path" : "/admin/user",
    "operations" : [ {
      "httpMethod" : "POST",
      "summary" : "Create User",
      "notes" : "",
      "nickname" : "adminUserCreate",
      "type" : "string",
      "parameters" : [ {
        "name" : "name",
        "paramType" : "form",
        "type" : "string",
        "description" : "",
        "required" : true
      }, {
        "name" : "password",
        "paramType" : "form",
        "type" : "string",
        "description" : "",
        "required" : true
      }, {
        "name" : "format",
        "paramType" : "query",
        "type" : "string",
        "description" : "For API client: set `json`",
        "required" : false
      }, {
        "name" : "X-BasicAuthName",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user name",
        "required" : false
      }, {
        "name" : "X-BasicAuthPassword",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user password",
        "required" : false
      }, {
        "name" : "age",
        "paramType" : "form",
        "type" : "int",
        "description" : "",
        "required" : false
      }, {
        "name" : "desc",
        "paramType" : "form",
        "type" : "string",
        "description" : "",
        "required" : false
      } ],
      "responseMessages" : [ {
        "code" : 401,
        "message" : "Unauthorized as admin user"
      }, {
        "code" : 200,
        "message" : "status = 0: Success to create user, status = 1: Failed to create user"
      }, {
        "code" : 400,
        "message" : "Invalid request parameter"
      } ],
      "produces" : [ ],
      "consumes" : [ ]
    } ]
  }, {
    "path" : "/admin/user/{name}",
    "operations" : [ {
      "httpMethod" : "PUT",
      "summary" : "Update User",
      "notes" : "",
      "nickname" : "adminUserUpdate",
      "type" : "string",
      "parameters" : [ {
        "name" : "name",
        "paramType" : "path",
        "type" : "string",
        "description" : "",
        "required" : true
      }, {
        "name" : "format",
        "paramType" : "query",
        "type" : "string",
        "description" : "For API client: set `json`",
        "required" : false
      }, {
        "name" : "X-BasicAuthName",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user name",
        "required" : false
      }, {
        "name" : "X-BasicAuthPassword",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user password",
        "required" : false
      }, {
        "name" : "password",
        "paramType" : "form",
        "type" : "string",
        "description" : "",
        "required" : false
      }, {
        "name" : "age",
        "paramType" : "form",
        "type" : "int",
        "description" : "",
        "required" : false
      }, {
        "name" : "desc",
        "paramType" : "form",
        "type" : "string",
        "description" : "",
        "required" : false
      } ],
      "responseMessages" : [ {
        "code" : 401,
        "message" : "Unauthorized as admin user"
      }, {
        "code" : 200,
        "message" : "status = 0: Success to update user, status = 1: Failed to update user"
      }, {
        "code" : 400,
        "message" : "Invalid request parameter"
      } ],
      "produces" : [ ],
      "consumes" : [ ]
    } ]
  }, {
    "path" : "/admin/user/{name}",
    "operations" : [ {
      "httpMethod" : "DELETE",
      "summary" : "Update user info",
      "notes" : "",
      "nickname" : "adminUserDelete",
      "type" : "string",
      "parameters" : [ {
        "name" : "name",
        "paramType" : "path",
        "type" : "string",
        "description" : "",
        "required" : true
      }, {
        "name" : "format",
        "paramType" : "query",
        "type" : "string",
        "description" : "For API client: set `json`",
        "required" : false
      }, {
        "name" : "X-BasicAuthName",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user name",
        "required" : false
      }, {
        "name" : "X-BasicAuthPassword",
        "paramType" : "header",
        "type" : "string",
        "description" : "For API client: set basicAuth user password",
        "required" : false
      } ],
      "responseMessages" : [ {
        "code" : 401,
        "message" : "Unauthorized as admin user"
      }, {
        "code" : 200,
        "message" : "status = 0: Success to delete user, status = 1: Failed to delete user"
      }, {
        "code" : 400,
        "message" : "Invalid request parameter"
      } ],
      "produces" : [ ],
      "consumes" : [ ]
    } ]
  } ]
}

http://localhost:8000/xitrum/swagger/auth

{
  "swaggerVersion" : "1.2",
  "apiVersion" : "1.0-SNAPSHOT",
  "basePath" : "http://localhost:8000",
  "resourcePath" : "/auth",
  "apis" : [ {
    "path" : "/logout",
    "operations" : [ {
      "httpMethod" : "GET",
      "summary" : "",
      "notes" : "All request will be redirect to LoginIndex",
      "nickname" : "logoutAction",
      "type" : "string",
      "parameters" : [ ],
      "responseMessages" : [ {
        "code" : 200,
        "message" : "Success to logout"
      } ],
      "produces" : [ ],
      "consumes" : [ ]
    } ]
  }, {
    "path" : "/login",
    "operations" : [ {
      "httpMethod" : "GET",
      "summary" : "Display login form",
      "notes" : "",
      "nickname" : "loginIndex",
      "type" : "string",
      "parameters" : [ ],
      "responseMessages" : [ {
        "code" : 200,
        "message" : "show index"
      } ],
      "produces" : [ ],
      "consumes" : [ ]
    } ]
  }, {
    "path" : "/",
    "operations" : [ {
      "httpMethod" : "GET",
      "summary" : "Display login form",
      "notes" : "",
      "nickname" : "loginIndex",
      "type" : "string",
      "parameters" : [ ],
      "responseMessages" : [ {
        "code" : 200,
        "message" : "show index"
      } ],
      "produces" : [ ],
      "consumes" : [ ]
    } ]
  }, {
    "path" : "/login",
    "operations" : [ {
      "httpMethod" : "POST",
      "summary" : "Authenticate user",
      "notes" : "Success: request will be redirect to ChatIndex, Fail: request will be redirect to LoginIndex",
      "nickname" : "loginAction",
      "type" : "string",
      "parameters" : [ {
        "name" : "name",
        "paramType" : "form",
        "type" : "string",
        "description" : "",
        "required" : true
      }, {
        "name" : "password",
        "paramType" : "form",
        "type" : "string",
        "description" : "",
        "required" : true
      } ],
      "responseMessages" : [ {
        "code" : 200,
        "message" : "redirect to chatIndex"
      } ],
      "produces" : [ ],
      "consumes" : [ ]
    } ]
  } ]
}
@georgeOsdDev georgeOsdDev changed the title ArrayIndexOutOfBoundsException with Swagger-codegen [Swagger] ArrayIndexOutOfBoundsException with Swagger-codegen Aug 28, 2014
@georgeOsdDev georgeOsdDev added this to the Xitrum 3.19 milestone Aug 28, 2014
@ngocdaothanh ngocdaothanh modified the milestones: Xitrum 3.20, Xitrum 3.19 Oct 30, 2014
@ngocdaothanh ngocdaothanh removed this from the Xitrum 3.22 milestone Jan 13, 2015
@ngocdaothanh
Copy link
Member

Moved to xitrum-framework/xitrum-swagger#1

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants