Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
19f05c68f8 | ||
|
|
5a12bd9cce | ||
|
|
e22b374bdd | ||
|
|
fe3749d499 | ||
|
|
85ef7f252d | ||
|
|
f16b563a82 |
@@ -138,3 +138,9 @@
|
||||
* PR #293: Fixed crash on empty tables
|
||||
* Updated markup-document-builder from 1.1.1 to 1.1.2
|
||||
|
||||
=== Version 1.3.3
|
||||
* Updated swagger-parser from v1.0.25 to 1.0.35
|
||||
* PR #294: Examples always start with a newline if there is other content in the same cell
|
||||
* PR 307: Include required parameters in example request
|
||||
|
||||
|
||||
|
||||
@@ -12,8 +12,8 @@ buildscript {
|
||||
}
|
||||
}
|
||||
description = 'swagger2markup Build'
|
||||
version = '1.3.2-SNAPSHOT'
|
||||
ext.releaseVersion = '1.3.1'
|
||||
version = '1.3.3'
|
||||
ext.releaseVersion = '1.3.3'
|
||||
group = 'io.github.swagger2markup'
|
||||
|
||||
apply plugin: 'java'
|
||||
@@ -40,7 +40,7 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
compile 'io.github.swagger2markup:markup-document-builder:1.1.2'
|
||||
compile 'io.swagger:swagger-compat-spec-parser:1.0.31'
|
||||
compile 'io.swagger:swagger-compat-spec-parser:1.0.35'
|
||||
compile 'org.apache.commons:commons-configuration2:2.1'
|
||||
compile 'commons-beanutils:commons-beanutils:1.9.2'
|
||||
compile 'org.apache.commons:commons-collections4:4.1'
|
||||
|
||||
@@ -139,8 +139,13 @@ public final class PropertyAdapter {
|
||||
Property items = arrayProperty.getItems();
|
||||
if (items == null)
|
||||
type = new ArrayType(arrayProperty.getTitle(), new ObjectType(null, null)); // FIXME : Workaround for Swagger parser issue with composed models (https://github.com/Swagger2Markup/swagger2markup/issues/150)
|
||||
else
|
||||
type = new ArrayType(arrayProperty.getTitle(), new PropertyAdapter(items).getType(definitionDocumentResolver));
|
||||
else {
|
||||
Type arrayType = new PropertyAdapter(items).getType(definitionDocumentResolver);
|
||||
if (arrayType == null)
|
||||
type = new ArrayType(arrayProperty.getTitle(), new ObjectType(null, null)); // FIXME : Workaround for Swagger parser issue with composed models (https://github.com/Swagger2Markup/swagger2markup/issues/150)
|
||||
else
|
||||
type = new ArrayType(arrayProperty.getTitle(), new PropertyAdapter(items).getType(definitionDocumentResolver));
|
||||
}
|
||||
} else if (property instanceof MapProperty) {
|
||||
MapProperty mapProperty = (MapProperty) property;
|
||||
Property additionalProperties = mapProperty.getAdditionalProperties();
|
||||
@@ -161,7 +166,9 @@ public final class PropertyAdapter {
|
||||
} else if (property instanceof ObjectProperty) {
|
||||
type = new ObjectType(property.getTitle(), ((ObjectProperty) property).getProperties());
|
||||
} else {
|
||||
if (isNotBlank(property.getFormat())) {
|
||||
if (property.getType() == null) {
|
||||
return null;
|
||||
} else if (isNotBlank(property.getFormat())) {
|
||||
type = new BasicType(property.getType(), property.getTitle(), property.getFormat());
|
||||
} else {
|
||||
type = new BasicType(property.getType(), property.getTitle());
|
||||
|
||||
@@ -20,12 +20,15 @@ import ch.netzwerg.paleo.StringColumn;
|
||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.swagger2markup.internal.adapter.PropertyAdapter;
|
||||
import io.github.swagger2markup.internal.resolver.DocumentResolver;
|
||||
import io.github.swagger2markup.internal.type.BasicType;
|
||||
import io.github.swagger2markup.internal.type.ObjectType;
|
||||
import io.github.swagger2markup.internal.type.Type;
|
||||
import io.github.swagger2markup.internal.utils.ModelUtils;
|
||||
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
|
||||
import io.github.swagger2markup.model.PathOperation;
|
||||
import io.github.swagger2markup.spi.MarkupComponent;
|
||||
import io.github.swagger2markup.spi.PathsDocumentExtension;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.Response;
|
||||
import io.swagger.models.properties.Property;
|
||||
import io.swagger.util.Json;
|
||||
@@ -46,11 +49,13 @@ import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
public class ResponseComponent extends MarkupComponent<ResponseComponent.Parameters> {
|
||||
|
||||
private final TableComponent tableComponent;
|
||||
private final Map<String, Model> definitions;
|
||||
private final DocumentResolver definitionDocumentResolver;
|
||||
|
||||
ResponseComponent(Swagger2MarkupConverter.Context context,
|
||||
DocumentResolver definitionDocumentResolver) {
|
||||
super(context);
|
||||
this.definitions = context.getSwagger().getDefinitions();
|
||||
this.definitionDocumentResolver = Validate.notNull(definitionDocumentResolver, "DocumentResolver must not be null");
|
||||
this.tableComponent = new TableComponent(context);
|
||||
}
|
||||
@@ -81,9 +86,15 @@ public class ResponseComponent extends MarkupComponent<ResponseComponent.Paramet
|
||||
Map<String, Response> sortedResponses = toSortedMap(responses, config.getResponseOrdering());
|
||||
sortedResponses.forEach((String responseName, Response response) -> {
|
||||
String schemaContent = labels.getLabel(NO_CONTENT);
|
||||
if (response.getSchema() != null) {
|
||||
Property property = response.getSchema();
|
||||
Type type = new PropertyAdapter(property).getType(definitionDocumentResolver);
|
||||
if (response.getResponseSchema() != null) {
|
||||
Model model = response.getResponseSchema();
|
||||
Type type = null;
|
||||
|
||||
if (model != null) {
|
||||
type = ModelUtils.getType(model, definitions, definitionDocumentResolver);
|
||||
} else {
|
||||
type = new BasicType("string", responseName);
|
||||
}
|
||||
|
||||
if (config.isInlineSchemaEnabled()) {
|
||||
type = createInlineType(type, labels.getLabel(RESPONSE) + " " + responseName, operation.getId() + " " + labels.getLabel(RESPONSE) + " " + responseName, params.inlineDefinitions);
|
||||
|
||||
@@ -16,6 +16,11 @@
|
||||
|
||||
package io.github.swagger2markup.internal.utils;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.github.swagger2markup.internal.adapter.ParameterAdapter;
|
||||
import io.github.swagger2markup.internal.adapter.PropertyAdapter;
|
||||
import io.github.swagger2markup.internal.resolver.DocumentResolver;
|
||||
@@ -28,11 +33,7 @@ import io.swagger.models.properties.ArrayProperty;
|
||||
import io.swagger.models.properties.MapProperty;
|
||||
import io.swagger.models.properties.Property;
|
||||
import io.swagger.models.properties.RefProperty;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import io.swagger.models.utils.PropertyModelConverter;
|
||||
|
||||
public class ExamplesUtil {
|
||||
|
||||
@@ -55,19 +56,22 @@ public class ExamplesUtil {
|
||||
Response response = responseEntry.getValue();
|
||||
Object example = response.getExamples();
|
||||
if (example == null) {
|
||||
Property schema = response.getSchema();
|
||||
if (schema != null) {
|
||||
example = schema.getExample();
|
||||
Model model = response.getResponseSchema();
|
||||
if (model != null) {
|
||||
Property schema = new PropertyModelConverter().modelToProperty(model);
|
||||
if (schema != null) {
|
||||
example = schema.getExample();
|
||||
|
||||
if (example == null && schema instanceof RefProperty) {
|
||||
String simpleRef = ((RefProperty) schema).getSimpleRef();
|
||||
example = generateExampleForRefModel(generateMissingExamples, simpleRef, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
|
||||
}
|
||||
if (example == null && schema instanceof ArrayProperty && generateMissingExamples) {
|
||||
example = generateExampleForArrayProperty((ArrayProperty) schema, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
|
||||
}
|
||||
if (example == null && generateMissingExamples) {
|
||||
example = PropertyAdapter.generateExample(schema, markupDocBuilder);
|
||||
if (example == null && schema instanceof RefProperty) {
|
||||
String simpleRef = ((RefProperty) schema).getSimpleRef();
|
||||
example = generateExampleForRefModel(generateMissingExamples, simpleRef, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
|
||||
}
|
||||
if (example == null && schema instanceof ArrayProperty && generateMissingExamples) {
|
||||
example = generateExampleForArrayProperty((ArrayProperty) schema, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
|
||||
}
|
||||
if (example == null && generateMissingExamples) {
|
||||
example = PropertyAdapter.generateExample(schema, markupDocBuilder);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -143,19 +147,17 @@ public class ExamplesUtil {
|
||||
String pathExample = (String) examples.get("path");
|
||||
pathExample = pathExample.replace('{' + parameter.getName() + '}', String.valueOf(abstractSerializableParameterExample));
|
||||
example = pathExample;
|
||||
} else if (parameter instanceof QueryParameter) {
|
||||
if (parameter.getRequired())
|
||||
{
|
||||
String path = (String) examples.get("path");
|
||||
String separator = path.contains("?") ? "&" : "?";
|
||||
String pathExample = path + separator + parameter.getName() + "=" + String.valueOf(abstractSerializableParameterExample);
|
||||
examples.put("path", pathExample);
|
||||
}
|
||||
} else {
|
||||
example = abstractSerializableParameterExample;
|
||||
}
|
||||
if (parameter instanceof QueryParameter) {
|
||||
//noinspection unchecked
|
||||
@SuppressWarnings("unchecked")
|
||||
Map<String, Object> queryExampleMap = (Map<String, Object>) examples.get("query");
|
||||
if (queryExampleMap == null) {
|
||||
queryExampleMap = new LinkedHashMap<>();
|
||||
}
|
||||
queryExampleMap.put(parameter.getName(), abstractSerializableParameterExample);
|
||||
example = queryExampleMap;
|
||||
}
|
||||
}
|
||||
} else if (parameter instanceof RefParameter) {
|
||||
String simpleRef = ((RefParameter) parameter).getSimpleRef();
|
||||
|
||||
@@ -69,7 +69,9 @@ public final class ModelUtils {
|
||||
objectType.getPolymorphism().setDiscriminator(modelImpl.getDiscriminator());
|
||||
|
||||
return objectType;
|
||||
} else if (isNotBlank(modelImpl.getFormat()))
|
||||
} else if (modelImpl.getType() == null)
|
||||
return null;
|
||||
else if (isNotBlank(modelImpl.getFormat()))
|
||||
return new BasicType(modelImpl.getType(), modelImpl.getTitle(), modelImpl.getFormat());
|
||||
else
|
||||
return new BasicType(modelImpl.getType(), modelImpl.getTitle());
|
||||
@@ -84,7 +86,10 @@ public final class ModelUtils {
|
||||
|
||||
for (Model innerModel : composedModel.getAllOf()) {
|
||||
Type innerModelType = resolveRefType(getType(innerModel, definitions, definitionDocumentResolver));
|
||||
name = innerModelType.getName();
|
||||
|
||||
if (innerModelType != null) {
|
||||
name = innerModelType.getName();
|
||||
}
|
||||
|
||||
if (innerModelType instanceof ObjectType) {
|
||||
|
||||
|
||||
@@ -15,13 +15,9 @@
|
||||
*/
|
||||
package io.github.swagger2markup;
|
||||
|
||||
import io.github.swagger2markup.assertions.DiffUtils;
|
||||
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
|
||||
import io.github.swagger2markup.markup.builder.MarkupLanguage;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
|
||||
import static org.assertj.core.api.BDDAssertions.assertThat;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.URISyntaxException;
|
||||
@@ -32,9 +28,14 @@ import java.nio.file.Paths;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static java.util.Arrays.asList;
|
||||
import static org.assertj.core.api.Assertions.failBecauseExceptionWasNotThrown;
|
||||
import static org.assertj.core.api.BDDAssertions.assertThat;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import io.github.swagger2markup.assertions.DiffUtils;
|
||||
import io.github.swagger2markup.builder.Swagger2MarkupConfigBuilder;
|
||||
import io.github.swagger2markup.markup.builder.MarkupLanguage;
|
||||
|
||||
public class AsciidocConverterTest {
|
||||
|
||||
@@ -345,6 +346,31 @@ public class AsciidocConverterTest {
|
||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithGeneratedRecursiveExamples.html");
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testWithGeneratedExamplesAndRequiredQueryParameters() throws IOException, URISyntaxException {
|
||||
//Given
|
||||
String swaggerJsonString = IOUtils.toString(getClass().getResourceAsStream("/yaml/swagger_examples_required_parameters.yaml"));
|
||||
Path outputDirectory = Paths.get("build/test/asciidoc/generated_examples_required_parameters");
|
||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
||||
|
||||
//When
|
||||
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
|
||||
.withGeneratedExamples()
|
||||
.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/generated_examples_required_parameters").toURI());
|
||||
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithGeneratedExamplesAndRequiredParameters.html");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWithInlineSchema() throws IOException, URISyntaxException {
|
||||
//Given
|
||||
|
||||
@@ -62,15 +62,6 @@ __optional__|Tags to filter by|< string > array(multi)
|
||||
----
|
||||
|
||||
|
||||
===== Request query
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"tags" : "adorable"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
==== Example HTTP response
|
||||
|
||||
===== Response 200
|
||||
|
||||
@@ -251,15 +251,6 @@ __optional__|Status values that need to be considered for filter|< string > arra
|
||||
----
|
||||
|
||||
|
||||
===== Request query
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"status" : "string"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
==== Example HTTP response
|
||||
|
||||
===== Response 200
|
||||
@@ -345,15 +336,6 @@ __optional__|Tags to filter by|< string > array(multi)
|
||||
----
|
||||
|
||||
|
||||
===== Request query
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"tags" : "string"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
==== Example HTTP response
|
||||
|
||||
===== Response 200
|
||||
@@ -1031,16 +1013,6 @@ __optional__|The user name for login|string|`"testUser"`
|
||||
----
|
||||
|
||||
|
||||
===== Request query
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"password" : "string",
|
||||
"username" : "string"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
==== Example HTTP response
|
||||
|
||||
===== Response 200
|
||||
|
||||
@@ -251,15 +251,6 @@ __optional__|Status values that need to be considered for filter|< string > arra
|
||||
----
|
||||
|
||||
|
||||
===== Request query
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"status" : "string"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
==== Example HTTP response
|
||||
|
||||
===== Response 200
|
||||
@@ -345,15 +336,6 @@ __optional__|Tags to filter by|< string > array(multi)
|
||||
----
|
||||
|
||||
|
||||
===== Request query
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"tags" : "string"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
==== Example HTTP response
|
||||
|
||||
===== Response 200
|
||||
@@ -1031,16 +1013,6 @@ __optional__|The user name for login|string|`"testUser"`
|
||||
----
|
||||
|
||||
|
||||
===== Request query
|
||||
[source,json]
|
||||
----
|
||||
{
|
||||
"password" : "string",
|
||||
"username" : "string"
|
||||
}
|
||||
----
|
||||
|
||||
|
||||
==== Example HTTP response
|
||||
|
||||
===== Response 200
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
|
||||
[[_definitions]]
|
||||
== Definitions
|
||||
|
||||
[[_category]]
|
||||
=== Category
|
||||
|
||||
[options="header", cols=".^3a,.^11a,.^4a"]
|
||||
|===
|
||||
|Name|Description|Schema
|
||||
|**id** +
|
||||
__optional__|**Example** : `0`|integer (int64)
|
||||
|**name** +
|
||||
__optional__|**Example** : `"string"`|string
|
||||
|===
|
||||
|
||||
|
||||
[[_pet]]
|
||||
=== Pet
|
||||
|
||||
[options="header", cols=".^3a,.^11a,.^4a"]
|
||||
|===
|
||||
|Name|Description|Schema
|
||||
|**category** +
|
||||
__optional__|**Example** : <<_category>>|<<_category,Category>>
|
||||
|**id** +
|
||||
__optional__|**Example** : `0`|integer (int64)
|
||||
|**name** +
|
||||
__required__|**Example** : `"doggie"`|string
|
||||
|**photoUrls** +
|
||||
__required__|**Example** : `[ "string" ]`|< string > array
|
||||
|**status** +
|
||||
__optional__|pet status in the store +
|
||||
**Example** : `"string"`|enum (available, pending, sold)
|
||||
|**tags** +
|
||||
__optional__|**Example** : `[ "<<_tag>>" ]`|< <<_tag,Tag>> > array
|
||||
|===
|
||||
|
||||
|
||||
[[_tag]]
|
||||
=== Tag
|
||||
|
||||
[options="header", cols=".^3a,.^11a,.^4a"]
|
||||
|===
|
||||
|Name|Description|Schema
|
||||
|**id** +
|
||||
__optional__|**Example** : `0`|integer (int64)
|
||||
|**name** +
|
||||
__optional__|**Example** : `"string"`|string
|
||||
|===
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
= Swagger Petstore
|
||||
|
||||
|
||||
[[_overview]]
|
||||
== Overview
|
||||
This is a sample server Petstore server. You can find out more about Swagger at http://swagger.io or on http://swagger.io/irc/["irc.freenode.net, #swagger"]. 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 Email__ : apiteam@swagger.io
|
||||
|
||||
|
||||
=== License information
|
||||
[%hardbreaks]
|
||||
__License__ : Apache 2.0
|
||||
__License URL__ : http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
__Terms of service__ : http://swagger.io/terms/
|
||||
|
||||
|
||||
=== URI scheme
|
||||
[%hardbreaks]
|
||||
__Host__ : petstore.swagger.io
|
||||
__BasePath__ : /v2
|
||||
__Schemes__ : HTTP
|
||||
|
||||
|
||||
=== Tags
|
||||
|
||||
* pet : Everything about your Pets
|
||||
* store : Access to Petstore orders
|
||||
* user : Operations about user
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,246 @@
|
||||
|
||||
[[_paths]]
|
||||
== Paths
|
||||
|
||||
[[_findpetsbycategory]]
|
||||
=== Finds Pets by category and status
|
||||
....
|
||||
GET /pet/findByCategory
|
||||
....
|
||||
|
||||
|
||||
==== Parameters
|
||||
|
||||
[options="header", cols=".^2a,.^3a,.^9a,.^4a"]
|
||||
|===
|
||||
|Type|Name|Description|Schema
|
||||
|**Query**|**category** +
|
||||
__required__|Category name that needs to be considered for filter|string
|
||||
|**Query**|**optional** +
|
||||
__optional__|Optional filter parameter|integer
|
||||
|**Query**|**status** +
|
||||
__required__|Status values that need to be considered for filter|< enum (available, pending, sold) > array(multi)
|
||||
|===
|
||||
|
||||
|
||||
==== Responses
|
||||
|
||||
[options="header", cols=".^2a,.^14a,.^4a"]
|
||||
|===
|
||||
|HTTP Code|Description|Schema
|
||||
|**200**|successful operation|< <<_pet,Pet>> > array
|
||||
|**400**|Invalid status value|No Content
|
||||
|===
|
||||
|
||||
|
||||
==== Produces
|
||||
|
||||
* `application/xml`
|
||||
* `application/json`
|
||||
|
||||
|
||||
==== Tags
|
||||
|
||||
* pet
|
||||
|
||||
|
||||
==== Security
|
||||
|
||||
[options="header", cols=".^3a,.^4a,.^13a"]
|
||||
|===
|
||||
|Type|Name|Scopes
|
||||
|**oauth2**|**<<_petstore_auth,petstore_auth>>**|write:pets,read:pets
|
||||
|===
|
||||
|
||||
|
||||
==== Example HTTP request
|
||||
|
||||
===== Request path
|
||||
----
|
||||
/pet/findByCategory?category=Herding&status=string
|
||||
----
|
||||
|
||||
|
||||
==== Example HTTP response
|
||||
|
||||
===== Response 200
|
||||
[source,json]
|
||||
----
|
||||
[ {
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"id" : 0,
|
||||
"name" : "string"
|
||||
},
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "string" ],
|
||||
"tags" : [ {
|
||||
"id" : 0,
|
||||
"name" : "string"
|
||||
} ],
|
||||
"status" : "string"
|
||||
} ]
|
||||
----
|
||||
|
||||
|
||||
[[_findpetsbyfunnypath]]
|
||||
=== Finds Pets with funny/illegal path
|
||||
....
|
||||
GET /pet/findByFunnyPath?always=1
|
||||
....
|
||||
|
||||
|
||||
==== Parameters
|
||||
|
||||
[options="header", cols=".^2a,.^3a,.^9a,.^4a"]
|
||||
|===
|
||||
|Type|Name|Description|Schema
|
||||
|**Query**|**category** +
|
||||
__required__|Category name that needs to be considered for filter|string
|
||||
|**Query**|**optional** +
|
||||
__optional__|Optional filter parameter|integer
|
||||
|===
|
||||
|
||||
|
||||
==== Responses
|
||||
|
||||
[options="header", cols=".^2a,.^14a,.^4a"]
|
||||
|===
|
||||
|HTTP Code|Description|Schema
|
||||
|**200**|successful operation|< <<_pet,Pet>> > array
|
||||
|**400**|Invalid status value|No Content
|
||||
|===
|
||||
|
||||
|
||||
==== Produces
|
||||
|
||||
* `application/xml`
|
||||
* `application/json`
|
||||
|
||||
|
||||
==== Tags
|
||||
|
||||
* pet
|
||||
|
||||
|
||||
==== Security
|
||||
|
||||
[options="header", cols=".^3a,.^4a,.^13a"]
|
||||
|===
|
||||
|Type|Name|Scopes
|
||||
|**oauth2**|**<<_petstore_auth,petstore_auth>>**|write:pets,read:pets
|
||||
|===
|
||||
|
||||
|
||||
==== Example HTTP request
|
||||
|
||||
===== Request path
|
||||
----
|
||||
/pet/findByFunnyPath?always=1&category=Herding
|
||||
----
|
||||
|
||||
|
||||
==== Example HTTP response
|
||||
|
||||
===== Response 200
|
||||
[source,json]
|
||||
----
|
||||
[ {
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"id" : 0,
|
||||
"name" : "string"
|
||||
},
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "string" ],
|
||||
"tags" : [ {
|
||||
"id" : 0,
|
||||
"name" : "string"
|
||||
} ],
|
||||
"status" : "string"
|
||||
} ]
|
||||
----
|
||||
|
||||
|
||||
[[_findpetsbystatus]]
|
||||
=== Finds Pets by status
|
||||
....
|
||||
GET /pet/findByStatus
|
||||
....
|
||||
|
||||
|
||||
==== Description
|
||||
Multiple status values can be provided with comma separated strings
|
||||
|
||||
|
||||
==== Parameters
|
||||
|
||||
[options="header", cols=".^2a,.^3a,.^9a,.^4a"]
|
||||
|===
|
||||
|Type|Name|Description|Schema
|
||||
|**Query**|**status** +
|
||||
__required__|Status values that need to be considered for filter|< enum (available, pending, sold) > array(multi)
|
||||
|===
|
||||
|
||||
|
||||
==== Responses
|
||||
|
||||
[options="header", cols=".^2a,.^14a,.^4a"]
|
||||
|===
|
||||
|HTTP Code|Description|Schema
|
||||
|**200**|successful operation|< <<_pet,Pet>> > array
|
||||
|**400**|Invalid status value|No Content
|
||||
|===
|
||||
|
||||
|
||||
==== Produces
|
||||
|
||||
* `application/xml`
|
||||
* `application/json`
|
||||
|
||||
|
||||
==== Tags
|
||||
|
||||
* pet
|
||||
|
||||
|
||||
==== Security
|
||||
|
||||
[options="header", cols=".^3a,.^4a,.^13a"]
|
||||
|===
|
||||
|Type|Name|Scopes
|
||||
|**oauth2**|**<<_petstore_auth,petstore_auth>>**|write:pets,read:pets
|
||||
|===
|
||||
|
||||
|
||||
==== Example HTTP request
|
||||
|
||||
===== Request path
|
||||
----
|
||||
/pet/findByStatus?status=string
|
||||
----
|
||||
|
||||
|
||||
==== Example HTTP response
|
||||
|
||||
===== Response 200
|
||||
[source,json]
|
||||
----
|
||||
[ {
|
||||
"id" : 0,
|
||||
"category" : {
|
||||
"id" : 0,
|
||||
"name" : "string"
|
||||
},
|
||||
"name" : "doggie",
|
||||
"photoUrls" : [ "string" ],
|
||||
"tags" : [ {
|
||||
"id" : 0,
|
||||
"name" : "string"
|
||||
} ],
|
||||
"status" : "string"
|
||||
} ]
|
||||
----
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
|
||||
[[_securityscheme]]
|
||||
== Security
|
||||
|
||||
[[_petstore_auth]]
|
||||
=== petstore_auth
|
||||
[%hardbreaks]
|
||||
__Type__ : oauth2
|
||||
__Flow__ : implicit
|
||||
__Token URL__ : http://petstore.swagger.io/oauth/dialog
|
||||
|
||||
|
||||
[options="header", cols=".^3a,.^17a"]
|
||||
|===
|
||||
|Name|Description
|
||||
|write:pets|modify pets in your account
|
||||
|read:pets|read your pets
|
||||
|===
|
||||
|
||||
|
||||
[[_api_key]]
|
||||
=== api_key
|
||||
[%hardbreaks]
|
||||
__Type__ : apiKey
|
||||
__Name__ : api_key
|
||||
__In__ : HEADER
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,219 @@
|
||||
swagger: "2.0"
|
||||
info:
|
||||
description: "This is a sample server Petstore server. You can find out more about Swagger at [http://swagger.io](http://swagger.io) or on [irc.freenode.net, #swagger](http://swagger.io/irc/). For this sample, you can use the api key `special-key` to test the authorization filters."
|
||||
version: "1.0.0"
|
||||
title: "Swagger Petstore"
|
||||
termsOfService: "http://swagger.io/terms/"
|
||||
contact:
|
||||
email: "apiteam@swagger.io"
|
||||
license:
|
||||
name: "Apache 2.0"
|
||||
url: "http://www.apache.org/licenses/LICENSE-2.0.html"
|
||||
host: "petstore.swagger.io"
|
||||
basePath: "/v2"
|
||||
tags:
|
||||
- name: "pet"
|
||||
description: "Everything about your Pets"
|
||||
externalDocs:
|
||||
description: "Find out more"
|
||||
url: "http://swagger.io"
|
||||
- name: "store"
|
||||
description: "Access to Petstore orders"
|
||||
- name: "user"
|
||||
description: "Operations about user"
|
||||
externalDocs:
|
||||
description: "Find out more about our store"
|
||||
url: "http://swagger.io"
|
||||
schemes:
|
||||
- "http"
|
||||
paths:
|
||||
|
||||
/pet/findByStatus:
|
||||
get:
|
||||
tags:
|
||||
- "pet"
|
||||
summary: "Finds Pets by status"
|
||||
description: "Multiple status values can be provided with comma separated strings"
|
||||
operationId: "findPetsByStatus"
|
||||
produces:
|
||||
- "application/xml"
|
||||
- "application/json"
|
||||
parameters:
|
||||
- name: "status"
|
||||
in: "query"
|
||||
description: "Status values that need to be considered for filter"
|
||||
required: true
|
||||
type: "array"
|
||||
items:
|
||||
type: "string"
|
||||
enum:
|
||||
- "available"
|
||||
- "pending"
|
||||
- "sold"
|
||||
default: "available"
|
||||
collectionFormat: "multi"
|
||||
responses:
|
||||
200:
|
||||
description: "successful operation"
|
||||
schema:
|
||||
type: "array"
|
||||
items:
|
||||
$ref: "#/definitions/Pet"
|
||||
400:
|
||||
description: "Invalid status value"
|
||||
security:
|
||||
- petstore_auth:
|
||||
- "write:pets"
|
||||
- "read:pets"
|
||||
/pet/findByCategory:
|
||||
get:
|
||||
tags:
|
||||
- "pet"
|
||||
summary: "Finds Pets by category and status"
|
||||
operationId: "findPetsByCategory"
|
||||
produces:
|
||||
- "application/xml"
|
||||
- "application/json"
|
||||
parameters:
|
||||
- name: "category"
|
||||
in: "query"
|
||||
description: "Category name that needs to be considered for filter"
|
||||
required: true
|
||||
type: "string"
|
||||
x-example: "Herding"
|
||||
- name: "optional"
|
||||
in: "query"
|
||||
description: "Optional filter parameter"
|
||||
required: false
|
||||
type: "integer"
|
||||
- name: "status"
|
||||
in: "query"
|
||||
description: "Status values that need to be considered for filter"
|
||||
required: true
|
||||
type: "array"
|
||||
items:
|
||||
type: "string"
|
||||
enum:
|
||||
- "available"
|
||||
- "pending"
|
||||
- "sold"
|
||||
default: "available"
|
||||
collectionFormat: "multi"
|
||||
responses:
|
||||
200:
|
||||
description: "successful operation"
|
||||
schema:
|
||||
type: "array"
|
||||
items:
|
||||
$ref: "#/definitions/Pet"
|
||||
400:
|
||||
description: "Invalid status value"
|
||||
security:
|
||||
- petstore_auth:
|
||||
- "write:pets"
|
||||
- "read:pets"
|
||||
/pet/findByFunnyPath?always=1:
|
||||
get:
|
||||
tags:
|
||||
- "pet"
|
||||
summary: "Finds Pets with funny/illegal path"
|
||||
operationId: "findPetsByFunnyPath"
|
||||
produces:
|
||||
- "application/xml"
|
||||
- "application/json"
|
||||
parameters:
|
||||
- name: "category"
|
||||
in: "query"
|
||||
description: "Category name that needs to be considered for filter"
|
||||
required: true
|
||||
type: "string"
|
||||
x-example: "Herding"
|
||||
- name: "optional"
|
||||
in: "query"
|
||||
description: "Optional filter parameter"
|
||||
required: false
|
||||
type: "integer"
|
||||
responses:
|
||||
200:
|
||||
description: "successful operation"
|
||||
schema:
|
||||
type: "array"
|
||||
items:
|
||||
$ref: "#/definitions/Pet"
|
||||
400:
|
||||
description: "Invalid status value"
|
||||
security:
|
||||
- petstore_auth:
|
||||
- "write:pets"
|
||||
- "read:pets"
|
||||
|
||||
securityDefinitions:
|
||||
petstore_auth:
|
||||
type: "oauth2"
|
||||
authorizationUrl: "http://petstore.swagger.io/oauth/dialog"
|
||||
flow: "implicit"
|
||||
scopes:
|
||||
write:pets: "modify pets in your account"
|
||||
read:pets: "read your pets"
|
||||
api_key:
|
||||
type: "apiKey"
|
||||
name: "api_key"
|
||||
in: "header"
|
||||
definitions:
|
||||
Category:
|
||||
type: "object"
|
||||
properties:
|
||||
id:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
name:
|
||||
type: "string"
|
||||
xml:
|
||||
name: "Category"
|
||||
Tag:
|
||||
type: "object"
|
||||
properties:
|
||||
id:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
name:
|
||||
type: "string"
|
||||
xml:
|
||||
name: "Tag"
|
||||
Pet:
|
||||
type: "object"
|
||||
required:
|
||||
- "name"
|
||||
- "photoUrls"
|
||||
properties:
|
||||
id:
|
||||
type: "integer"
|
||||
format: "int64"
|
||||
category:
|
||||
$ref: "#/definitions/Category"
|
||||
name:
|
||||
type: "string"
|
||||
example: "doggie"
|
||||
photoUrls:
|
||||
type: "array"
|
||||
xml:
|
||||
name: "photoUrl"
|
||||
wrapped: true
|
||||
items:
|
||||
type: "string"
|
||||
tags:
|
||||
type: "array"
|
||||
xml:
|
||||
name: "tag"
|
||||
wrapped: true
|
||||
items:
|
||||
$ref: "#/definitions/Tag"
|
||||
status:
|
||||
type: "string"
|
||||
description: "pet status in the store"
|
||||
enum:
|
||||
- "available"
|
||||
- "pending"
|
||||
- "sold"
|
||||
xml:
|
||||
name: "Pet"
|
||||
Reference in New Issue
Block a user