forked from loafle/openapi-generator-original
updated instructions, package
This commit is contained in:
parent
6a9ba75640
commit
d6f5231e93
62
README.md
62
README.md
@ -32,7 +32,66 @@ cd samples/petstore/scala
|
|||||||
mvn package
|
mvn package
|
||||||
```
|
```
|
||||||
|
|
||||||
Do the same for `java` by running `./bin/java-petstore.sh`
|
Other languages have samples, too:
|
||||||
|
```
|
||||||
|
./bin/flash-petstore.sh
|
||||||
|
./bin/java-petstore.sh
|
||||||
|
./bin/php-petstore.sh
|
||||||
|
./bin/python-petstore.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
### Generating your own libraries
|
||||||
|
It's just as easy--you can either run the default generators:
|
||||||
|
|
||||||
|
```
|
||||||
|
./bin/runscala.sh com.wordnik.swagger.codegen.BasicScalaGenerator http://petstore.swagger.wordnik.com/api/resources.json special-key
|
||||||
|
```
|
||||||
|
|
||||||
|
Replace `Scala` with `Flash`, `PHP`, `Python`, `Java`.
|
||||||
|
|
||||||
|
You will probably want to override some of the defaults--like packages, etc. For doing this, just create a scala
|
||||||
|
script with the overrides you want. Follow [ScalaPetstoreCodegen](https://github.com/wordnik/swagger-codegen/blob/master/src/main/scala/ScalaPetstoreCodegen.scala) as an example:
|
||||||
|
|
||||||
|
For example, create `src/main/scala/MyCodegen.scala` with these contents:
|
||||||
|
|
||||||
|
```
|
||||||
|
import com.wordnik.swagger.codegen.BasicScalaGenerator
|
||||||
|
import com.wordnik.swagger.core._
|
||||||
|
|
||||||
|
object MyCodegen extends BasicScalaGenerator {
|
||||||
|
def main(args: Array[String]) = generateClient(args)
|
||||||
|
|
||||||
|
// where to write generated code
|
||||||
|
override def destinationDir = "client/scala/src/main/scala"
|
||||||
|
|
||||||
|
// api invoker package
|
||||||
|
override def packageName = "com.myapi.client"
|
||||||
|
|
||||||
|
// package for models
|
||||||
|
override def modelPackage = Some("com.myapi.client.model")
|
||||||
|
|
||||||
|
// package for api classes
|
||||||
|
override def apiPackage = Some("com.myapi.client.api")
|
||||||
|
|
||||||
|
// supporting classes
|
||||||
|
override def supportingFiles = List(
|
||||||
|
("apiInvoker.mustache", destinationDir + java.io.File.separator + packageName.replaceAll("\\.", java.io.File.separator), "ApiInvoker.scala"),
|
||||||
|
("pom.mustache", destinationDir, "pom.xml")
|
||||||
|
)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Now you can generate your client like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
./bin/runscala.sh src/main/scala/MyCodegen.scala http://my.api.com/resources.json super-secret-key
|
||||||
|
```
|
||||||
|
|
||||||
|
w00t! Thanks to the scala interpretor, you didn't even need to recompile.
|
||||||
|
|
||||||
|
### Where is Javascript???
|
||||||
|
See our [javascript library](http://github.com/wordnik/swagger.js)--it's completely dynamic and doesn't require
|
||||||
|
static code generation.
|
||||||
|
|
||||||
|
|
||||||
#### Generating a client from flat files
|
#### Generating a client from flat files
|
||||||
@ -50,7 +109,6 @@ Or for example:
|
|||||||
|
|
||||||
Which simple passes `-DfileMap=src/test/resources/petstore` as an argument
|
Which simple passes `-DfileMap=src/test/resources/petstore` as an argument
|
||||||
|
|
||||||
|
|
||||||
### Validating your swagger spec
|
### Validating your swagger spec
|
||||||
You can use the validation tool to see that your server is creating a proper spec file. If you want to learn
|
You can use the validation tool to see that your server is creating a proper spec file. If you want to learn
|
||||||
more about the spec file and format, please see [swagger-core](https://github.com/wordnik/swagger-core/wiki). This
|
more about the spec file and format, please see [swagger-core](https://github.com/wordnik/swagger-core/wiki). This
|
||||||
|
@ -1,28 +0,0 @@
|
|||||||
/**
|
|
||||||
* Copyright 2012 Wordnik, Inc.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import com.wordnik.swagger.codegen.BasicGenerator
|
|
||||||
|
|
||||||
import com.wordnik.swagger.core._
|
|
||||||
|
|
||||||
object ScalaCodegen extends ScalaCodegen {
|
|
||||||
def main(args: Array[String]) = generateClient(args)
|
|
||||||
}
|
|
||||||
|
|
||||||
class ScalaCodegen extends BasicGenerator {
|
|
||||||
// location of templates
|
|
||||||
override def templateDir = "scala"
|
|
||||||
}
|
|
Loading…
x
Reference in New Issue
Block a user