All Projects → mulesoft-labs → raml-java-client-generator

mulesoft-labs / raml-java-client-generator

Licence: Apache-2.0 license
Raml Java Client Generator

Programming Languages

java
68154 projects - #9 most used programming language
RAML
58 projects

Projects that are alternatives of or similar to raml-java-client-generator

raml-javascript-generator
Generate a JavaScript API client from RAML
Stars: ✭ 30 (-6.25%)
Mutual labels:  raml, raml-tooling, raml-codegen
api-console-cli
A CLI tools for the API console.
Stars: ✭ 14 (-56.25%)
Mutual labels:  raml, raml-tooling
raml-sublime-plugin
Syntax highlighter for the RESTful API Modeling Language
Stars: ✭ 49 (+53.13%)
Mutual labels:  raml, raml-tooling
raml2obj
RAML to object.
Stars: ✭ 23 (-28.12%)
Mutual labels:  raml, raml-tooling
raml-typesystem
(deprecated) Typescript implementation of RAML type system
Stars: ✭ 15 (-53.12%)
Mutual labels:  raml, raml-tooling
node-raml-validate
Strict validation of RAML parameters in JavaScript
Stars: ✭ 18 (-43.75%)
Mutual labels:  raml, raml-tooling
raml-dotnet-parser-2
No description or website provided.
Stars: ✭ 17 (-46.87%)
Mutual labels:  raml, raml-tooling
osprey-method-handler
Middleware for validating requests and responses based on a RAML method object
Stars: ✭ 14 (-56.25%)
Mutual labels:  raml, raml-tooling
oas-raml-converter
(DEPRECATED) Converts between OAS and RAML API specifications
Stars: ✭ 75 (+134.38%)
Mutual labels:  raml, raml-tooling
Raml Examples
This repository contains valid RAML 1.0 examples. These examples are not only part of the spec, but also represent RAML features in different scenarios.
Stars: ✭ 154 (+381.25%)
Mutual labels:  raml
smockin
Dynamic API, S3 & Mail mocking for web, mobile & microservice development.
Stars: ✭ 74 (+131.25%)
Mutual labels:  raml
Raml Js Parser 2
(deprecated)
Stars: ✭ 140 (+337.5%)
Mutual labels:  raml
Raml Server
run a mocked server JUST based on a RAML API's definition .. zero coding
Stars: ✭ 158 (+393.75%)
Mutual labels:  raml
Hikaku
A library that tests if the implementation of a REST-API meets its specification.
Stars: ✭ 154 (+381.25%)
Mutual labels:  raml
Osprey Mock Service
Generate an API mock service from a RAML definition using Osprey
Stars: ✭ 106 (+231.25%)
Mutual labels:  raml
Raml Client Generator
Template-driven generator of clients for APIs described by a RAML spec
Stars: ✭ 119 (+271.88%)
Mutual labels:  raml
core
This repo contains the core module of the OCF API's.
Stars: ✭ 20 (-37.5%)
Mutual labels:  raml
generaptr
Generaptr is a node package that helps when starting up a project by generating boilerplate code for Express api.
Stars: ✭ 16 (-50%)
Mutual labels:  raml
Ramlfications
Python parser for RAML
Stars: ✭ 234 (+631.25%)
Mutual labels:  raml
Api Workbench
The API Workbench for RAML (deprecated)
Stars: ✭ 222 (+593.75%)
Mutual labels:  raml

RAML Client Generator

alt text

This tool generates a java rest client for a raml based api using a resource api approach. Supports both 0.8 and 1.0 versions of Raml

Example

For this api

#%RAML 0.8
title: Client API
version: 0.1
baseUri: http://mycompany.com/clientservice/api
documentation:
  - title : Users Platform
    content : This api describes how to access to the users platform
mediaType: application/json
/users:
  description: "Users in the platform"
  get:
    description: "Returns the list of all users"
    responses:
      200:
        body:
          application/json:
            example: |
             [{"user" : "Mariano"}]

Using the generated api

final ClientAPIResponse<List<UsersGETResponseBody>> result = ClientAPIClient.create().users.get();

Customizing the client

final ClientAPIClient client = new ClientAPIClient() {
    @Override
    protected Client getClient() {
        final Client client = ClientBuilder.newClient();
        client.property(ClientProperties.CONNECT_TIMEOUT, 1000);
        client.property(ClientProperties.READ_TIMEOUT, 1000);
        return client;
    }
};
client.users.userId("luis").get();

Calling the code generator from Java

It can easily be embedded the code generation into your code just. Add the dependency to pom.xml

  <dependency>
        <groupId>org.mule.raml.codegen</groupId>
        <artifactId>raml-client-generator-core</artifactId>
        <version>0.11</version>
  </dependency>

Note: Since the RAML Java Client Generator artifacts are not published to Maven Central you will also have to add the following repository either to your pom.xml or an active profile in your maven settings.

  <repositories>
    <repository>
      <id>mulesoft-releases</id>
      <name>Mule Release Repository</name>
      <url>https://repository-master.mulesoft.org/nexus/content/repositories/releases</url>
    </repository>
  </repositories>

And then call the RamlJavaClientGenerator

 new RamlJavaClientGenerator(
                "com.acme",
                targetFolder).generate(this.getClass().getClassLoader().getResource("simple/basic.raml"));

Generate client code from RAML using the maven plugin

There is also a maven plugin that allows you to generate the client code during your build process.

    <build>
        <plugins>
            <plugin>
                <groupId>org.mule.raml.codegen</groupId>
                <artifactId>raml-client-generator-maven-plugin</artifactId>
                <version>0.11</version>
                <executions>
                    <execution>
                        <goals>
                            <goal>generate-client</goal>
                        </goals>
                        <configuration>
                            <basePackage>org.mule.example</basePackage>
                            <useJava8Dates>false</useJava8Dates>                            
                            <!--True by default                            -->
                            <includeAdditionalProperties>true</includeAdditionalProperties>
                            <!--False by default                            -->
                            <useOptionalForGetters>false</useOptionalForGetters>
                            <!--False by default                            -->
                            <useBigDecimals>false</useBigDecimals>
                        </configuration>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>

Note: Since the RAML Java Client Generator artifacts are not published to Maven Central you will also have to add the following plugin repository either to your pom.xml or an active profile in your maven settings.

  <pluginRepositories>
    <pluginRepository>
      <id>mulesoft-releases</id>
      <name>Mule Release Repository</name>
      <url>https://repository-master.mulesoft.org/nexus/content/repositories/releases</url>
    </pluginRepository>
  </pluginRepositories>

Disclaimer

This is an incubator project (so expect bugs) so no mulesoft oficial support. If any issue is detected please report an issue and we will try to fix it. Also PR are welcome.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].