This file contains hidden or 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
# process for creating a scala library for a swagger-enabled server | |
# build the codegen | |
ant | |
# generate the client library with the default (empty) api_key | |
./bin/generate-scala-lib.sh http://api.wordnik.com/v4 "" com.wordnik.client generated | |
# copy the sample build script | |
cp conf/scala/sample/* generated/ |
This file contains hidden or 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
package com.wordnik.client | |
import com.wordnik.client.api._ | |
import com.wordnik.client.model._ | |
import com.wordnik.swagger.runtime.common._ | |
object Test { | |
def main(args: Array[String]) = { | |
val securityHandler = new ApiKeyAuthTokenBasedSecurityHandler("{YOUR_KEY}", null) |
This file contains hidden or 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
@GET | |
@Path("/findByStatus") | |
@ApiOperation(value = "Finds Pets by status", | |
notes = "Multiple status values can be provided with comma seperated strings", | |
responseClass = "com.wordnik.swagger.sample.model.Pet", multiValueResponse = true) | |
@ApiErrors(Array( | |
new ApiError(code = 400, reason = "Invalid status value"))) | |
def findPetsByStatus( | |
@ApiParam(value = "Status values that need to be considered for filter", required = true, defaultValue = "available", | |
allowableValues = "available,pending,sold", allowMultiple = true)@QueryParam("status") status: String) = { |
This file contains hidden or 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
override def onMessage(s: String) { | |
val objs = deserializers.filter(d => matchd(l, d)) | |
objs.size match { | |
case 0 => //oops, nothing can do it | |
case _ => objs(0).deserialize(s) | |
} | |
} |
This file contains hidden or 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
import java.util.Date | |
// define some classes | |
case class Child (name: String, birthdate: Date) | |
case class Spouse (name: String, birthdate: Date) | |
case class Address (address1: String, | |
address2: String, | |
city: String, | |
state: String, |
This file contains hidden or 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
<script type="text/javascript"> | |
$(function () { | |
window.swaggerUi = new SwaggerUi({ | |
discoveryUrl:"http://localhost:8002/api/api-docs.json", | |
apiKeyName:"apikey", | |
dom_id:"swagger-ui-container", | |
supportHeaderParams: true, | |
supportedSubmitMethods: ['get', 'post', 'put'], | |
onComplete: function(swaggerApi, swaggerUi){ | |
if(console) { |
This file contains hidden or 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
DocumentationObject obj = new DocumentationObject(); | |
obj.setName("Manual"); | |
obj.addField(new DocumentationParameter( | |
"fieldA", // attribute name | |
"The field of Manual", // description, optional | |
"Notes", // notes about this field, optional | |
"String", // the attribute type | |
null, // default value, null if none | |
null, // allowable values, null if none |
This file contains hidden or 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
/* | |
in your web.xml, specify this as a custom reader | |
<init-param> | |
<param-name>swagger.config.reader</param-name> | |
<param-value>com.wordnik.swagger.sample.CustomConfigReader</param-value> | |
</init-param> | |
*/ |
This file contains hidden or 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
git clone [email protected]:wordnik/swagger-codegen.git | |
./sbt assembly | |
# generate java library in generated-code/java | |
scala -cp target/swagger-codegen-assembly-2.0.2-SNAPSHOT.jar com.wordnik.swagger.codegen.BasicJavaGenerator http://developers.subtledata.com/swagger/api-docs.json | |
# build the library | |
cd generated-code/java | |
mvn package |
This file contains hidden or 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
// install the swagger-client | |
npm install swagger-client | |
// start the node repl | |
node | |
> var swagger = require("swagger-client"); | |
> var s = new swagger.SwaggerApi("http://petstore.swagger.wordnik.com/api/api-docs.json"); | |
// build the swagger client | |
> s.build(); |
OlderNewer