build.sbt
name := "swagger-validator"
libraryDependencies ++= Seq(
"com.github.fge" % "json-schema-validator" % "2.1.7"
)| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> | |
| <modelVersion>4.0.0</modelVersion> | |
| <groupId>com.wordnik</groupId> | |
| <artifactId>test</artifactId> | |
| <packaging>jar</packaging> | |
| <name>test</name> | |
| <version>1.0.0-SNAPSHOT</version> | |
| <prerequisites> | |
| <maven>2.2.0</maven> |
build.sbt
name := "swagger-validator"
libraryDependencies ++= Seq(
"com.github.fge" % "json-schema-validator" % "2.1.7"
)| commons-lang-2.4.jar | |
| dom4j-1.6.1.jar | |
| guava-11.0.2.jar | |
| jackson-annotations-2.1.5.jar | |
| jackson-core-2.1.5.jar | |
| jackson-databind-2.1.5.jar | |
| jackson-jaxrs-json-provider-2.0.0.jar | |
| jackson-module-jaxb-annotations-2.0.0.jar | |
| jackson-module-jsonSchema-2.1.0.jar | |
| jackson-module-scala_2.10-2.1.5.jar |
| // 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(); |
| 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 |
| /* | |
| 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> | |
| */ |
| 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 |
| <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) { |
| 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, |
| 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) | |
| } | |
| } |