raml-for-jax-rs icon indicating copy to clipboard operation
raml-for-jax-rs copied to clipboard

Client generator

Open WenTingZhu opened this issue 9 years ago • 7 comments

Should this be: if(generateClientStringValue!=null){ generateClient = Boolean.parseBoolean(generateClientStringValue); } instead of: if(removeOldOutputStringValue!=null){ generateClient = Boolean.parseBoolean(generateClientStringValue); }

https://github.com/mulesoft/raml-for-jax-rs/blob/e3bbfe523460d9b9e77907773cc7d543f0ce782e/raml-to-jaxrs/core/src/main/java/org/raml/jaxrs/codegen/core/Launcher.java#L58

WenTingZhu avatar Jul 14 '15 20:07 WenTingZhu

Hi, @WenTingZhu

Here is the place where we insert command line options into generators configuration: https://github.com/mulesoft/raml-for-jax-rs/blob/e3bbfe523460d9b9e77907773cc7d543f0ce782e/raml-to-jaxrs/core/src/main/java/org/raml/jaxrs/codegen/core/Launcher.java#L110-167

I will implement handling of missing arguments before the end of the week.

Regards, Konstantin

KonstantinSviridov avatar Jul 15 '15 22:07 KonstantinSviridov

Hi Konstantin, the configuration for generateClient is handled up in line57 of Launcher, and I don't think it is necessary to add it into the createConfiguration method?

WenTingZhu avatar Jul 16 '15 13:07 WenTingZhu

Also, I think for the annotation type parameter to work, the name of the property has to match the name of the variable. Otherwise the generateClient variable does not change value with changes in the maven pom file.

https://github.com/mulesoft/raml-for-jax-rs/blob/e3bbfe523460d9b9e77907773cc7d543f0ce782e/raml-to-jaxrs/maven-plugin/src/main/java/org/raml/jaxrs/codegen/maven/RamlJaxrsCodegenMojo.java#L114

WenTingZhu avatar Jul 16 '15 13:07 WenTingZhu

As for Line 57, you're right. And I think that it's better to have the whole configuration filled in the same place. Otherwise I will always forget that "generateClient" is set somewhere else.

As for maven, for some strange reason it only works fine when the field name equals property name. I've pushed the fix to GitHub and I will soon deploy it to sonatype and mule repo.

KonstantinSviridov avatar Jul 16 '15 16:07 KonstantinSviridov

Hi,

is it in the maven central already? I've inserted the generateClientProxy argument to the maven config, but what I get generated is still only the service JAX-RS part... Am I missing something? The extension below is just about the name change of the generated resource interface.

Thanks in advance...

            <plugin>
                <groupId>org.raml.plugins</groupId>
                <artifactId>raml-jaxrs-maven-plugin</artifactId>
                <version>1.3.4-SNAPSHOT</version>
                <configuration>
                    <!-- Use sourcePaths if you want to provide a single RAML file or a
                        list of RAML files -->
                    <sourcePaths>
                        <param>${resourceDirectory}/api/image-repo-service.raml</param>
                    </sourcePaths>
                    <sourceDirectory>${resourceDirectory}/api</sourceDirectory>
                    <!-- Optionally configure outputDirectory if you don't like the default
                        value: ${project.build.directory}/generated-sources/raml-JAX-RS -->
                    <outputDirectory>${project.build.directory}/generated-sources</outputDirectory>
                    <!-- Replace with your package name -->
                    <basePackageName>sample.imagerepo.client</basePackageName>
                    <generateClientProxy>true</generateClientProxy>
                    <!-- Valid values: 1.1 2.0 -->
                    <jaxrsVersion>2.0</jaxrsVersion>
                    <useJsr303Annotations>true</useJsr303Annotations>
                    <!-- Valid values: jackson1 jackson2 gson none -->
                    <jsonMapper>gson</jsonMapper>
                    <removeOldOutput>true</removeOldOutput>
            <extensions>
                <extension>sample.raml.ImageBuilderExtension</extension>
                    </extensions>
                </configuration>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <phase>generate-sources</phase>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>sample</groupId>
                        <artifactId>raml-generator-ext</artifactId>
                        <version>0.0.1-SNAPSHOT</version>
                    </dependency>
                </dependencies>
            </plugin>

ok11 avatar Aug 21 '15 08:08 ok11

I looked at the source code and did not find where the ClientGenerator or GeneratorProxy is called when using the maven build path. The GeneratorProxy is called from the Launcher, but it is more or less a command line-based generation, correct? Does it at the moment work only from the CLI?

ok11 avatar Aug 21 '15 08:08 ok11

2.0 client generation will come.

jpbelang avatar Dec 23 '17 03:12 jpbelang