Added simple json + test cases for validators #160´
This commit is contained in:
@@ -455,6 +455,30 @@ public class AsciidocConverterTest {
|
||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/enums").toURI());
|
||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionWithEnums.html");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testSwagger2AsciiDocConversionWithValidators() throws IOException, URISyntaxException {
|
||||
//Given
|
||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/json/swagger_validators.json").toURI());
|
||||
Path outputDirectory = Paths.get("build/test/asciidoc/validators");
|
||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
||||
|
||||
//When
|
||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
||||
.build();
|
||||
Swagger2MarkupConverter.from(file)
|
||||
.withConfig(config)
|
||||
.build()
|
||||
.toFolder(outputDirectory);
|
||||
|
||||
//Then
|
||||
String[] files = outputDirectory.toFile().list();
|
||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
||||
|
||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/validators").toURI());
|
||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testSwagger2AsciiDocConversionWithValidators.html");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwagger2AsciiDocConversionWithPolymorphism() throws IOException, URISyntaxException {
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
|
||||
[[_definitions]]
|
||||
== Definitions
|
||||
|
||||
[[_samplerequest]]
|
||||
=== SampleRequest
|
||||
|
||||
[options="header", cols=".^3,.^11,.^4"]
|
||||
|===
|
||||
|Name|Description|Schema
|
||||
|*sampleNumberComplete* +
|
||||
_optional_|sample int with range 0-10 +
|
||||
*Minimum value* : `0.0` +
|
||||
*Maximum value* : `10.0`|integer(int32)
|
||||
|*sampleNumberNoDescription* +
|
||||
_optional_|*Minimum value* : `0.0` +
|
||||
*Maximum value* : `10.0`|integer(int32)
|
||||
|*sampleNumberOnlyMaximum* +
|
||||
_optional_|*Maximum value* : `10.0`|integer(int32)
|
||||
|*sampleNumberOnlyMinimum* +
|
||||
_optional_|*Minimum value* : `0.0`|integer(int32)
|
||||
|*sampleStringComplete* +
|
||||
_optional_|Sample string with range 0-2 and a pattern +
|
||||
*Length* : `0 - 2` +
|
||||
*Pattern* : `"[A-Z0-9]{0,2}"`|string
|
||||
|*sampleStringOnlyMaxLength* +
|
||||
_optional_|*Maximal length* : `2`|string
|
||||
|*sampleStringOnlyMinLength* +
|
||||
_optional_|*Minimum length* : `0`|string
|
||||
|*sampleStringOnlyPattern* +
|
||||
_optional_|*Pattern* : `"[A-Z0-9]{0,2}"`|string
|
||||
|*sampleStringWithNoDescription* +
|
||||
_optional_|*Length* : `0 - 2` +
|
||||
*Pattern* : `"[A-Z0-9]{0,2}"`|string
|
||||
|===
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
= Title
|
||||
|
||||
|
||||
[[_overview]]
|
||||
== Overview
|
||||
Description
|
||||
|
||||
|
||||
=== Version information
|
||||
[%hardbreaks]
|
||||
_Version_ : Developer build
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
|
||||
|
||||
63
src/test/resources/json/swagger_validators.json
Normal file
63
src/test/resources/json/swagger_validators.json
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
"swagger": "2.0",
|
||||
"info": {
|
||||
"description": "Description",
|
||||
"version": "Developer build",
|
||||
"title": "Title"
|
||||
},
|
||||
"definitions": {
|
||||
"SampleRequest": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"sampleStringComplete": {
|
||||
"type": "string",
|
||||
"description": "Sample string with range 0-2 and a pattern",
|
||||
"minLength": 0,
|
||||
"maxLength": 2,
|
||||
"pattern": "[A-Z0-9]{0,2}"
|
||||
},
|
||||
"sampleStringWithNoDescription": {
|
||||
"type": "string",
|
||||
"minLength": 0,
|
||||
"maxLength": 2,
|
||||
"pattern": "[A-Z0-9]{0,2}"
|
||||
},
|
||||
"sampleStringOnlyMinLength": {
|
||||
"type": "string",
|
||||
"minLength": 0
|
||||
},
|
||||
"sampleStringOnlyMaxLength": {
|
||||
"type": "string",
|
||||
"maxLength": 2
|
||||
},
|
||||
"sampleStringOnlyPattern": {
|
||||
"type": "string",
|
||||
"pattern": "[A-Z0-9]{0,2}"
|
||||
},
|
||||
"sampleNumberComplete": {
|
||||
"type":"integer",
|
||||
"format":"int32",
|
||||
"description": "sample int with range 0-10",
|
||||
"minimum": 0,
|
||||
"maximum": 10
|
||||
},
|
||||
"sampleNumberNoDescription": {
|
||||
"type":"integer",
|
||||
"format":"int32",
|
||||
"minimum": 0,
|
||||
"maximum": 10
|
||||
},
|
||||
"sampleNumberOnlyMinimum": {
|
||||
"type":"integer",
|
||||
"format":"int32",
|
||||
"minimum": 0
|
||||
},
|
||||
"sampleNumberOnlyMaximum": {
|
||||
"type":"integer",
|
||||
"format":"int32",
|
||||
"maximum": 10
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user