-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from lanwen/readme
readme with example
- Loading branch information
Showing
5 changed files
with
115 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# RARC - Rest-Assured RAML Codegen | ||
|
||
This project simplifies generation of test clients | ||
(with [Rest-Assured lib](https://github.com/rest-assured/rest-assured/) under the hood) by your RAML spec. | ||
Currently this project pointed to [0.8](http://raml.org/raml-08-spec), but | ||
will be upgraded to [1.0](http://raml.org/raml-10-spec) soon. | ||
|
||
## Quick Start | ||
|
||
- Place your spec to `src/main/resources/api.raml` | ||
- Add to your `<build>` section in `pom.xml`: | ||
|
||
```xml | ||
<plugin> | ||
<groupId>ru.lanwen.raml</groupId> | ||
<artifactId>rarc-maven-plugin</artifactId> | ||
<executions> | ||
<execution> | ||
<goals> | ||
<goal>generate-client</goal> | ||
</goals> | ||
<configuration> | ||
<basePackage>ru.lanwen.raml.test</basePackage> | ||
</configuration> | ||
</execution> | ||
</executions> | ||
</plugin> | ||
``` | ||
|
||
- Add dependency to rest-assured (currently tested on `2.8.0`): | ||
|
||
```xml | ||
<dependency> | ||
<groupId>com.jayway.restassured</groupId> | ||
<artifactId>rest-assured</artifactId> | ||
<version>2.8.0</version> | ||
</dependency> | ||
``` | ||
|
||
- Run `mvn clean compile` | ||
- Use it! (Don't forget to add static imports and factory to base endpoint) | ||
|
||
```java | ||
ApiExample.example( | ||
ApiExample.Config.exampleConfig() | ||
.withReqSpecSupplier( | ||
() -> new RequestSpecBuilder().setBaseUri("http://your_host/") | ||
) | ||
) | ||
.rpcApi() | ||
.uid().withUid("1") | ||
.info() | ||
.get(identity()).prettyPeek(); | ||
``` | ||
|
||
See working example in `rarc-example` module. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
rarc-example/src/test/java/ru/lanwen/raml/test/ApiExampleUsageTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package ru.lanwen.raml.test; | ||
|
||
import com.jayway.restassured.builder.RequestSpecBuilder; | ||
import org.junit.Ignore; | ||
import org.junit.Test; | ||
|
||
import static java.util.function.Function.identity; | ||
|
||
/** | ||
* @author lanwen (Merkushev Kirill) | ||
*/ | ||
@Ignore | ||
public class ApiExampleUsageTest { | ||
|
||
@Test | ||
public void shouldBeAbleToCompile() throws Exception { | ||
ApiExample.example( | ||
ApiExample.Config.exampleConfig() | ||
.withReqSpecSupplier( | ||
() -> new RequestSpecBuilder().setBaseUri("http://your_host/") | ||
) | ||
) | ||
.rpcApi() | ||
.uid().withUid("1") | ||
.info() | ||
.get(identity()).prettyPeek(); | ||
|
||
} | ||
} |