Skip to content

Commit

Permalink
Merge pull request #96 from maxlinc/structure
Browse files Browse the repository at this point in the history
Structure
  • Loading branch information
fehguy committed Aug 12, 2014
2 parents ca7017d + 4cdabbf commit ef3729d
Show file tree
Hide file tree
Showing 108 changed files with 85 additions and 83 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
*.ipr
*.iws
target
atlassian-ide-plugin.xml
atlassian-ide-plugin.xml
node_modules/
Gemfile.lock
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
16 changes: 8 additions & 8 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ var exitCode = 0;

var json_paths = {
examples: 'examples/**/*.json',
models: 'samples/v2.0/json/models/**/*.json',
resources: 'samples/v2.0/json/resources/**/*.json',
responses: 'samples/v2.0/json/responses/**/*.json'
// What are the other files in samples/v2.0/json/*.json
models: 'fixtures/v2.0/json/models/**/*.json',
resources: 'fixtures/v2.0/json/resources/**/*.json',
responses: 'fixtures/v2.0/json/responses/**/*.json'
// What are the other files in fixtures/v2.0/json/*.json
};

gulp.task('lint', function() {
Expand All @@ -26,23 +26,23 @@ gulp.task('lint', function() {
});

gulp.task('yaml2json', function(){
gulp.src('./samples/v2.0/yaml/**.yaml')
gulp.src('./fixtures/v2.0/yaml/**.yaml')
.pipe(gulpyaml({ pretty: true }))
.pipe(gulp.dest('./samples/v2.0/json'));
.pipe(gulp.dest('./fixtures/v2.0/json'));

gulp.src(json_paths.examples)
.pipe(gulpyaml({ pretty: true }))
.pipe(gulp.dest('examples/'));
});

gulp.task('json2yaml', function(){
return gulp.src('./samples/v2.0/json/**/*.json')
return gulp.src('./fixtures/v2.0/json/**/*.json')
.pipe(map(function(file, cb) {
data = JSON.parse(file.contents);
file.contents = new Buffer(String(YAML.stringify(data)));
cb(null, file);
}))
.pipe(ext_replace('.yaml'))
.pipe(gulp.dest('samples/v2.0/yaml'));
.pipe(gulp.dest('fixtures/v2.0/yaml'));
});

14 changes: 7 additions & 7 deletions src/test/scala/ModelTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ModelTest extends FlatSpec with ShouldMatchers with TestBase {
val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("schema"))

it should "validate a model with string property" in {
val json = Source.fromFile("samples/v2.0/json/models/modelWithStringProperty.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/models/modelWithStringProperty.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -27,7 +27,7 @@ class ModelTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a model with multiple properties" in {
val json = Source.fromFile("samples/v2.0/json/models/modelWithMultipleProperties.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/models/modelWithMultipleProperties.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -36,7 +36,7 @@ class ModelTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a model with an int32 map" in {
val json = Source.fromFile("samples/v2.0/json/models/modelWithInt32Map.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/models/modelWithInt32Map.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -45,7 +45,7 @@ class ModelTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a model with an int64 map" in {
val json = Source.fromFile("samples/v2.0/json/models/modelWithInt64Map.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/models/modelWithInt64Map.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -54,7 +54,7 @@ class ModelTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a model with an date-time map" in {
val json = Source.fromFile("samples/v2.0/json/models/modelWithDateTimeMap.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/models/modelWithDateTimeMap.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -63,11 +63,11 @@ class ModelTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a model with xml properties" in {
val json = Source.fromFile("samples/v2.0/json/models/modelWithXmlAttributes.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/models/modelWithXmlAttributes.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
println(report)
report.isSuccess should be (true)
}
}
}
10 changes: 5 additions & 5 deletions src/test/scala/ModelsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ModelsTest extends FlatSpec with ShouldMatchers with TestBase {
val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("schema"))

it should "validate a models hash" in {
val json = Source.fromFile("samples/v2.0/json/models/models.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/models/models.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -27,7 +27,7 @@ class ModelsTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate multiple models" in {
val json = Source.fromFile("samples/v2.0/json/models/multipleModels.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/models/multipleModels.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -36,7 +36,7 @@ class ModelsTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate models with examples" in {
val json = Source.fromFile("samples/v2.0/json/models/modelWithExamples.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/models/modelWithExamples.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -45,11 +45,11 @@ class ModelsTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate models with composition" in {
val json = Source.fromFile("samples/v2.0/json/models/modelWithComposition.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/models/modelWithComposition.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
println(report)
report.isSuccess should be (true)
}
}
}
8 changes: 4 additions & 4 deletions src/test/scala/OperationsTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class OperationsTest extends FlatSpec with ShouldMatchers with TestBase {
val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("operation"))

it should "validate a resource with string path param" in {
val json = Source.fromFile("samples/v2.0/json/resources/operations/stringPathParamResource.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/operations/stringPathParamResource.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -27,7 +27,7 @@ class OperationsTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a resource with string path param and boolean query param" in {
val json = Source.fromFile("samples/v2.0/json/resources/operations/stringPathAndBoolQueryParamResource.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/operations/stringPathAndBoolQueryParamResource.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -36,11 +36,11 @@ class OperationsTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a resource with tags in the operation" in {
val json = Source.fromFile("samples/v2.0/json/resources/operations/operationWithTags.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/operations/operationWithTags.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
println(report)
report.isSuccess should be (true)
}
}
}
36 changes: 18 additions & 18 deletions src/test/scala/ParameterTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
val jsonSchema = factory.getJsonSchema(schema.get("definitions").get("parameter"))

it should "validate a string query parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/queryStringParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/queryStringParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -27,7 +27,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate an int64 array query parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/queryInt64ArrayParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/queryInt64ArrayParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -36,14 +36,14 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "fail to validate a complex query parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/queryWithComplexParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/queryWithComplexParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
report.isSuccess should be (false)
}

it should "validate a string header parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/headerStringParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/headerStringParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -52,7 +52,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a string array header parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/headerStringArrayParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/headerStringArrayParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -61,7 +61,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a int64 array header parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/headerInt64ArrayParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/headerInt64ArrayParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -70,7 +70,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a string path parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/pathStringParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/pathStringParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -79,7 +79,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a int64 path parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/pathInt64Parameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/pathInt64Parameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -88,7 +88,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a string array path parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/pathStringArrayParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/pathStringArrayParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -97,7 +97,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate an int64 body parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/bodyInt64Parameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/bodyInt64Parameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -106,7 +106,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a string body parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/bodyStringParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/bodyStringParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -115,7 +115,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a string array body parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/bodyStringArrayParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/bodyStringArrayParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -124,7 +124,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a complex body parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/bodyComplexParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/bodyComplexParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -133,7 +133,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a complex body array parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/bodyComplexArrayParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/bodyComplexArrayParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -142,7 +142,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate an int64 form data parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/formDataInt64Parameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/formDataInt64Parameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -151,7 +151,7 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

it should "validate a string array form data parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/formDataStringArrayParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/formDataStringArrayParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
if(report.isSuccess == false)
Expand All @@ -160,9 +160,9 @@ class ParameterTest extends FlatSpec with ShouldMatchers with TestBase {
}

ignore should "fail to validate a complex form data parameter" in {
val json = Source.fromFile("samples/v2.0/json/resources/parameters/formDataComplexParameter.json").mkString
val json = Source.fromFile("fixtures/v2.0/json/resources/parameters/formDataComplexParameter.json").mkString
val data = JsonLoader.fromString(json)
val report = jsonSchema.validate(data)
report.isSuccess should be (false)
}
}
}
Loading

0 comments on commit ef3729d

Please sign in to comment.