forked from loafle/openapi-generator-original
added README
This commit is contained in:
parent
af5f8909a6
commit
9f5be1cf5a
63
samples/client/wordnik-api/java/README.md
Normal file
63
samples/client/wordnik-api/java/README.md
Normal file
@ -0,0 +1,63 @@
|
||||
# Wordnik Java client library
|
||||
|
||||
## Overview
|
||||
This is a full client library for the Wordnik API. It requires that you have a valid Wordnik API Key--you
|
||||
can get one for free at http://developer.wordnik.com.
|
||||
|
||||
This library is built using the Wordnik [Swagger](http://swagger.wordnik.com) client library generator. You
|
||||
can re-generate this library by running ./bin/java-wordnik-api.sh from the swagger-codegen project
|
||||
|
||||
## Usage
|
||||
Generate the client library with Maven:
|
||||
|
||||
```
|
||||
mvn package
|
||||
```
|
||||
|
||||
Add the library to your project and you're ready to go:
|
||||
|
||||
```java
|
||||
import com.wordnik.client.api.*;
|
||||
import com.wordnik.client.model.*;
|
||||
|
||||
import com.wordnik.client.common.ApiException;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Test {
|
||||
public static void main(String[] args) {
|
||||
if(args.length == 0) {
|
||||
System.out.println("Pass your API key as an argument");
|
||||
System.exit(0);
|
||||
}
|
||||
String key = args[0];
|
||||
|
||||
try {
|
||||
WordApi api = new WordApi();
|
||||
api.getInvoker().addDefaultHeader("api_key", key);
|
||||
List<Definition> definitions = api.getDefinitions(
|
||||
"Cat", // word
|
||||
"noun", // only get definitions which are "nouns"
|
||||
"wiktionary", // use wiktionary
|
||||
3, // fetch only 3 results max
|
||||
"true", // return related words
|
||||
"true", // fetch the canonical version of this word (Cat => cat)
|
||||
"false" // return XML mark-up in response
|
||||
);
|
||||
|
||||
for(Definition def : definitions) {
|
||||
System.out.print(def);
|
||||
}
|
||||
}
|
||||
catch (ApiException e) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
This project was built with the following minimum requirements:
|
||||
|
||||
* Maven 3.0
|
||||
* Java JDK 6
|
49
samples/client/wordnik-api/scala/README.md
Normal file
49
samples/client/wordnik-api/scala/README.md
Normal file
@ -0,0 +1,49 @@
|
||||
# Wordnik Scala client library
|
||||
|
||||
## Overview
|
||||
This is a full client library for the Wordnik API. It requires that you have a valid Wordnik API Key--you
|
||||
can get one for free at http://developer.wordnik.com.
|
||||
|
||||
This library is built using the Wordnik [Swagger](http://swagger.wordnik.com) client library generator. You
|
||||
can re-generate this library by running ./bin/scala-wordnik-api.sh from the swagger-codegen project
|
||||
|
||||
## Usage
|
||||
Generate the client library with Maven:
|
||||
|
||||
```
|
||||
mvn package -DskipTests=true
|
||||
```
|
||||
|
||||
Run the tests if you like--note, these require you have an active Wordnik API key, username, and password:
|
||||
|
||||
```
|
||||
mvn package -DAPI_KEY={YOUR_API_KEY} -DUSER_NAME={YOUR_USER_NAME} -DPASSWORD={YOUR_PASSWORD}
|
||||
```
|
||||
|
||||
Add the library to your project and you're ready to go:
|
||||
|
||||
```scala
|
||||
import com.wordnik.client.api._
|
||||
import com.wordnik.client.model._
|
||||
|
||||
object Test {
|
||||
def main(args: Array[String]) = {
|
||||
if(args.length == 0) {
|
||||
println("Please pass your API key")
|
||||
sys.exit(0)
|
||||
}
|
||||
val key = args(0)
|
||||
val api = new WordApi
|
||||
api.addHeader("api_key", key)
|
||||
api.getDefinitions("cat", null, null, 10).flatten.foreach(definition => {
|
||||
println(definition)
|
||||
})
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
|
||||
This project was built with the following minimum requirements:
|
||||
|
||||
* Maven 3.0
|
||||
* Java JDK 6
|
Loading…
x
Reference in New Issue
Block a user