mulesoft-labs / raml-java-client-generator

Raml Java Client Generator
Apache License 2.0
34 stars 34 forks source link

Unable to expose private API #16

Open rscadrde opened 6 years ago

rscadrde commented 6 years ago

Having a private API in

https://anypoint.mulesoft.com/apiplatform/---companyname---/#/portals/organizations/----organization-id----/apis/---api-number----/versions/---version-number--

it is not possible to pass any authentication / token informations as just new InputStreamReader(ramlURL.openStream())) is done in RamlJavaClientGenerator not allowing any basic auth or token header.

Result is always:

[ERROR] Failed to execute goal org.mule.raml.codegen:raml-client-generator-maven-plugin:0.1.1:generate-client (default-cli) on project : Exception while generating client. Server returned HTTP response code: 401

(setting API to public is not an option as it is a private one ;-) )

machaval commented 6 years ago

You can download it to local file system first and then generate it

rscadrde commented 6 years ago

For sure downloading is a workaround (as setting the API to public when generating is a workaround).

But as maven works it should be possible to execute ram-java-client-generator during some kind of execution-phase (e.g. process-resources) and re-generate the java files automatically.

Which is currently possible on

but not for private anypoint.mulesoft.com APIs (even not our private nor private from other parties shared with us).

As raml-java-client-generator is from mulesoft and the anypoint API platform is, it should be possible to somehow add anypoint credentials to access the APIs programmatically.

ca-stefan-cordes commented 5 years ago

With Design Center (Crowd Release?) the Artifacts from Exchange are available via Maven dependency

        <dependency>
            <groupId>6b05fd51-2fe5-4078-b1a1-83d46894bf7</groupId>
            <artifactId>mule-template1</artifactId>
            <version>1.0.4</version>
            <classifier>raml</classifier>
            <type>zip</type>
        </dependency>

and so I started using maven-dependency-plugin to copy them to the local directory and successully generated from the raml via

<ramlURL>file:////${project.build.directory}/copied-dependencies/mule-template1-1.0.4-raml-zip/api.raml</ramlURL>

That seems to be a good working solution.

So nothing to do here.

ca-stefan-cordes commented 5 years ago

Issue can be closed.