pmlopes / slush-vertx

36 stars 4 forks source link

Code generated for binary string file upload has syntax errors #15

Open InfoSec812 opened 5 years ago

InfoSec812 commented 5 years ago

For the following example snippet of OpenAPI spec:

    post:
      security:
      - ApiKeyAuth: []
      - BearerAuth: []
      description: Upload a new photo and get back the unique identifier
      operationId: addPhoto
      requestBody:
        content:
          image/*:
            schema:
              type: string
              format: binary

The generated method has syntax errors:

    /**
     * Call addPhoto with image/* buffer body. 
     * 
     * @param buffer Buffer that represents the body of the request
     * @param handler The handler for the asynchronous request
     */
    public void addPhotoWithImage*Buffer(
        Buffer buffer, Handler<AsyncResult<HttpResponse>> handler) {

Not sure what that should actually be. Probably a method which takes a Buffer as a parameter.

slinkydeveloper commented 5 years ago

Can you move to the new generator https://github.com/pmlopes/vertx-starter and check if the problem persists?

InfoSec812 commented 5 years ago

@slinkydeveloper How do I test that branch locally? I'm trying to run npm install -g and I get:

$ sudo npm install -g
npm ERR! path /usr/lib/node_modules/.staging/create-vertx-app-63e44608/node_modules/@babel/code-frame
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/lib/node_modules/.staging/create-vertx-app-63e44608/node_modules/@babel/code-frame' -> '/usr/lib/node_modules/.staging/@babel/code-frame-023c47cd'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2018-12-21T15_13_04_930Z-debug.log
InfoSec812 commented 5 years ago

I also tried running the cli from npm:

$ npm run cli 

> create-vertx-app@0.0.6 cli /home/Workspace/vertx-starter
> node src/cli_entrypoint.js

? Choose the build tool maven
? Project Name photo-archive
? Project Description (Optional) undefined
? Maven Group Id (Optional) com.example
? Maven Artifact Id (Optional) photo-archive
? Project Version (Optional) 0.0.1-SNAPSHOT
? GraalVM native-image No
? Choose your language java
? Choose the project type OpenAPI Server With Event Bus Services
? OpenAPI file (YAML or JSON) /home/Workspace/photo-archive/src/main/resources/openapi.yml
? Choose your additional dependencies 
ENOENT: no such file or directory, open '/home/Workspace/vertx-starter/blobs/mvnw.zip'
{ Error: ENOENT: no such file or directory, open '/home/Workspace/vertx-starter/blobs/mvnw.zip'
  errno: -2,
  code: 'ENOENT',
  syscall: 'open',
  path: '/home/Workspace/vertx-starter/blobs/mvnw.zip' }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! create-vertx-app@0.0.6 cli: `node src/cli_entrypoint.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the create-vertx-app@0.0.6 cli script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/.npm/_logs/2018-12-21T15_16_01_734Z-debug.log
InfoSec812 commented 5 years ago

OK, got it to run, but it's still generating Handlers instead of Services.

$ find src/main/java
src/main/java
src/main/java/com
src/main/java/com/example
src/main/java/com/example/photo_archive
src/main/java/com/example/photo_archive/handlers
src/main/java/com/example/photo_archive/handlers/AddUserToGroupHandler.java
src/main/java/com/example/photo_archive/handlers/GetImageByIdHandler.java
src/main/java/com/example/photo_archive/handlers/DeleteTagFromPhotoHandler.java
src/main/java/com/example/photo_archive/handlers/GetTagsByPhotoIdHandler.java
src/main/java/com/example/photo_archive/handlers/NewUserHandler.java
src/main/java/com/example/photo_archive/handlers/NewGroupHandler.java
src/main/java/com/example/photo_archive/handlers/UpdateGroupByIdHandler.java
src/main/java/com/example/photo_archive/handlers/AddTagToPhotoHandler.java
src/main/java/com/example/photo_archive/handlers/UpdateImageByIdHandler.java
src/main/java/com/example/photo_archive/handlers/UserLoginHandler.java
src/main/java/com/example/photo_archive/handlers/DeleteUserFromGroupHandler.java
src/main/java/com/example/photo_archive/handlers/AddPhotoHandler.java
src/main/java/com/example/photo_archive/handlers/GetGroupByIdHandler.java
src/main/java/com/example/photo_archive/handlers/DeleteGroupByIdHandler.java
src/main/java/com/example/photo_archive/handlers/DeleteImageByIdHandler.java
src/main/java/com/example/photo_archive/handlers/GetUserDetailsByNameHandler.java
src/main/java/com/example/photo_archive/models
src/main/java/com/example/photo_archive/models/NewGroup.java
src/main/java/com/example/photo_archive/models/User.java
src/main/java/com/example/photo_archive/models/package-info.java
src/main/java/com/example/photo_archive/models/Error.java
src/main/java/com/example/photo_archive/models/NewUser.java
src/main/java/com/example/photo_archive/models/Credentials.java
src/main/java/com/example/photo_archive/models/Group.java
src/main/java/com/example/photo_archive/models/ImageObject.java
src/main/java/com/example/photo_archive/services
src/main/java/com/example/photo_archive/services/package-info.java
src/main/java/com/example/photo_archive/MainVerticle.java
src/main/java/com/example/photo_archive/ApiClient.java
src/main/java/com/example/photo_archive/security
src/main/java/com/example/photo_archive/security/BearerAuthHandler.java
src/main/java/com/example/photo_archive/security/BasicAuthHandler.java
src/main/java/com/example/photo_archive/security/ApiKeyAuthHandler.java
InfoSec812 commented 5 years ago

Perhaps I am expecting the wrong thing. My expectations are:

slinkydeveloper commented 5 years ago

You must use an additional annotation to tell to generator how to map vertx eb addresses to eb services interfaces/implementations: https://github.com/pmlopes/vertx-starter/blob/develop/dist/webdocs/OpenAPI_Server_With_Services.md