Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

RAML containing multipart form data does not generate compileable code #334

Closed
cpkr opened this issue Feb 21, 2018 · 10 comments
Closed

RAML containing multipart form data does not generate compileable code #334

cpkr opened this issue Feb 21, 2018 · 10 comments

Comments

@cpkr
Copy link

cpkr commented Feb 21, 2018

We created a raml file containing a post request with mulitpart formdata. The fragment used is equivalent to the one in file jaxrs-to-raml-examples/jaxrs-to-raml-maven-examples/jaxrs-to-raml-multipart/target/generated-sources/raml-jaxrs/jaxrs-to-raml-multipart.raml from the currrent Snapshot:

/theMultiparts:
    post:
        body:
            multipart/form-data:
                type:
                    properties:
                        appBundle:
                            type: file

When generating the java code via maven the resource does contain a class for this parameter which had not been generated
I copied the file from the git repo to my project and generated the class. The same problem does occur. Following is generated for the post method:

  @POST
  @Consumes("multipart/form-data")
  PostTheMultipartsResponse postTheMultiparts(TheMultipartsPostMultipartFormData entity);

@jpbelang
Copy link
Contributor

is this on master ? Just to be clear the "TheMultipartsPostMultipartFormData" is not generated ?

@cpkr
Copy link
Author

cpkr commented Feb 21, 2018

It is on master Snapshot branch

@jpbelang
Copy link
Contributor

jpbelang commented Feb 25, 2018

I've built a plugin to handle this case. The reason I've built a plugin is that form data implementation are server specific (I may be wrong, but all examples I've seen seem to indicate this).

Look at the torture test for usage. Tell me if I missed something.

(branch release/3.0.0)

@cpkr
Copy link
Author

cpkr commented Feb 26, 2018

Thanks for the update. Unfortunately the branch release/3.0.0 does not compile to me:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.1:compile (default-compile) on project raml-defined-example: Compilation failure: Compilation failure:
[ERROR] /data/projects/dcep/git/raml-for-jax-rs/raml-to-jaxrs/examples/maven-examples/raml-defined-example/target/generated-sources/raml-to-jaxrs-maven-plugin/example/support/LimbDeserializer.java:[32,37] example.model.Limb is abstract; cannot be instantiated

@jpbelang
Copy link
Contributor

Are you sure you are up to date ? The travis-ci build is passing.

https://travis-ci.org/mulesoft-labs/raml-for-jax-rs

@cpkr
Copy link
Author

cpkr commented Feb 26, 2018

My fault. I did not do a clean install. I will try tomorrow with the file upload stuff and give you feedback. Thanks for your support.

@cpkr
Copy link
Author

cpkr commented Feb 27, 2018

Looks fine from the generated code. I will continue with the implementation and reply if also this part works.

Thanks for your support.

@cpkr
Copy link
Author

cpkr commented Mar 5, 2018

I found one issue in new implementation: If you have a uri parameter this is not generated as parameter.
Example:

/theMultiparts:
    /{uident}:
        description: File upload
        uriParameters:
            uident:
                description: uident - Uuid of the form
                type: string
        post:
            body:
                multipart/form-data:
                    type: object
                    properties:
                        appBundle:
                            type:
                                type: file
                                displayName:
                                    value: type
                            displayName:
                                value: appBundle
                    displayName:
                        value: "multipart/form-data"

Do you also have a solution for this one?

jpbelang added a commit that referenced this issue Mar 5, 2018
Added found parameters.
@jpbelang
Copy link
Contributor

jpbelang commented Mar 5, 2018

Just pushed a quick fix with minimal testing. Could you give it a try ?

@cpkr
Copy link
Author

cpkr commented Mar 6, 2018

It is working as expected. Many thanks for your support.

jpbelang added a commit that referenced this issue Mar 7, 2018
Forgot exception.  Not a big deal unless someone if adding them.
@jstoiko jstoiko closed this as completed Mar 20, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants