Skip to content
This repository has been archived by the owner on Mar 26, 2019. It is now read-only.

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

Open
InfoSec812 opened this issue Dec 19, 2018 · 6 comments
Open

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

InfoSec812 opened this issue Dec 19, 2018 · 6 comments

Comments

@InfoSec812
Copy link

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
Copy link
Collaborator

slinkydeveloper commented Dec 19, 2018

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

@InfoSec812
Copy link
Author

@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
Copy link
Author

I also tried running the cli from npm:

$ npm run cli 

> [email protected] 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! [email protected] cli: `node src/cli_entrypoint.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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
Copy link
Author

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
Copy link
Author

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

  • Each path prefix (e.g. /photo or /user) is a separate service (e.g. PhotoService or UserService)
  • Each operationId is a method in it's respective service
  • Each method in the service gets mapped to a operation in the OpenAPIRouter

@slinkydeveloper
Copy link
Collaborator

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

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

No branches or pull requests

2 participants