Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -384,13 +384,13 @@ private void exampleMap(MarkupDocBuilder markupDocBuilder, Map<String, Object> e
while (fieldsIterator.hasNext()) {
Map.Entry<String, JsonNode> field = fieldsIterator.next();

if (field.getKey().equals("application/json")) {
if (field.getKey().equals("application/json") || field.getKey().contains("+json")) {
String example = Json.pretty(field.getValue());
example = stripExampleQuotes(StringEscapeUtils.unescapeJson(example));

markupDocBuilder.listingBlock(example, "json");

} else if (field.getKey().equals("application/xml")) {
} else if (field.getKey().equals("application/xml") || field.getKey().contains("+xml")) {

String example = stripExampleQuotes(field.getValue().toString());
example = StringEscapeUtils.unescapeJava(example);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -400,6 +400,29 @@ public void testWithGeneratedInlineResponseExamples() throws IOException, URISyn
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithGeneratedInlineResponseExamples.html");
}

@Test
public void testWithExamplesAndMimeTypesSuffix() throws IOException, URISyntaxException {
//Given
String swaggerJsonString = IOUtils.toString(getClass().getResourceAsStream("/json/swagger_examples_suffix.json"), StandardCharsets.UTF_8);
Path outputDirectory = Paths.get("build/test/asciidoc/examples_suffix");
FileUtils.deleteQuietly(outputDirectory.toFile());

//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.build();

Swagger2MarkupConverter.from(swaggerJsonString)
.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/examples_suffix").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithExamples.html");
}

@Test
public void testWithInlineSchema() throws URISyntaxException {
//Given
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,146 @@

[[_definitions]]
== Definitions

[[_category]]
=== Category

[options="header", cols=".^3a,.^11a,.^4a"]
|===
|Name|Description|Schema
|**id** +
__optional__|**Example** : `123`|integer (int64)
|**name** +
__optional__|**Example** : `"Canines"`|string
|===


[[_complexobject]]
=== ComplexObject

[options="header", cols=".^3a,.^11a,.^4a"]
|===
|Name|Description|Schema
|**subObject** +
__optional__|**Example** : `{
"id" : 99,
"value" : "an example value !"
}`|<<_subobject,SubObject>>
|===

[[_subobject]]
**SubObject**

[options="header", cols=".^3a,.^11a,.^4a"]
|===
|Name|Description|Schema
|**id** +
__optional__|**Example** : `88`|integer (int64)
|**value** +
__optional__|**Example** : `"a value !"`|string
|===


[[_identified]]
=== Identified

[options="header", cols=".^3a,.^4a"]
|===
|Name|Schema
|**id** +
__optional__|integer (int64)
|===


[[_order]]
=== Order

[options="header", cols=".^3a,.^11a,.^4a"]
|===
|Name|Description|Schema
|**complete** +
__optional__||boolean
|**id** +
__optional__|**Example** : `77`|integer (int64)
|**petId** +
__optional__||integer (int64)
|**quantity** +
__optional__||integer (int32)
|**shipDate** +
__optional__||string (date-time)
|**status** +
__optional__|Order Status|enum (placed, approved, delivered)
|===


[[_pet]]
=== Pet
Test description


[options="header", cols=".^3a,.^11a,.^4a"]
|===
|Name|Description|Schema
|**category** +
__optional__||<<_category,Category>>
|**id** +
__optional__||integer (int64)
|**name** +
__required__|**Example** : `"doggie"`|string
|**nicknames** +
__optional__||< string, string > map
|**photoUrls** +
__required__||< string > array
|**status** +
__optional__|pet status in the store|string
|**tags** +
__optional__||< <<_tag,Tag>> > array
|**weight** +
__optional__|the weight of the pet|number
|===


[[_tag]]
=== Tag

[options="header", cols=".^3a,.^4a"]
|===
|Name|Schema
|**id** +
__optional__|integer (int64)
|**name** +
__optional__|string
|===


[[_user]]
=== User
[%hardbreaks]
__Polymorphism__ : Composition


[options="header", cols=".^3a,.^11a,.^4a"]
|===
|Name|Description|Schema
|**email** +
__optional__||string (email)
|**firstName** +
__optional__||string
|**id** +
__optional__||integer (int64)
|**lastName** +
__optional__||string
|**password** +
__optional__||string (password)
|**phone** +
__optional__||string
|**pictures** +
__optional__||< string (byte) > array
|**userStatus** +
__optional__|User Status|integer (int32)
|**username** +
__optional__||string
|===



Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
= Swagger Petstore API


[[_overview]]
== Overview
This is a sample server Petstore server.

http://swagger.wordnik.com[Learn about Swagger] or join the IRC channel `#swagger` on irc.freenode.net.

For this sample, you can use the api key `special-key` to test the authorization filters


=== Version information
[%hardbreaks]
__Version__ : 1.0.0


=== Contact information
[%hardbreaks]
__Contact__ : apiteam@wordnik.com


=== License information
[%hardbreaks]
__License__ : Apache 2.0
__License URL__ : http://www.apache.org/licenses/LICENSE-2.0.html
__Terms of service__ : http://helloreverb.com/terms/


=== URI scheme
[%hardbreaks]
__Host__ : petstore.swagger.wordnik.com
__BasePath__ : /v2
__Schemes__ : HTTP


=== Tags

* pet : Pet resource
* store : Store resource
* user : User resource



Loading