Compare commits

..

12 Commits

Author SHA1 Message Date
Cas Eliëns
052b417fdb Identify location where query parameter examples are generated 2017-10-02 20:03:06 +02:00
Cas Eliëns
8f16457e49 Adjust query parameter test to expect new query parameter formatting 2017-10-02 20:02:24 +02:00
Cas Eliëns
2d8f46f5f6 Clean up code 2017-10-02 19:08:30 +02:00
Cas Eliëns
2886d30dec Begin simplifying example generation code 2017-07-27 11:36:16 +02:00
Cas Eliëns
282e74becb Create unit test for query parameter example generation 2017-07-24 09:56:06 +02:00
Cas Eliëns
164b1ad2a8 Begin identifying source of issue in #264 2017-07-20 16:33:37 +02:00
brischniz
038ff3a40e ExternalDocs section will now be rendered in result document (#263)
* Typo fixed

* ExternalDocs section will now be rendered in result document
2017-07-17 09:13:41 +02:00
Magnus Larsson
6d8776332f Property refs are resolved as links and not as text (#265)
* Property refs are resolved as links and not as text

* Update static docs in tests to match change in code

* Remove unnecessary if check
2017-07-17 09:12:45 +02:00
Robert Winkler
4ea24b0297 Fixed typo in german language file 2017-07-11 09:01:41 +02:00
Robert Winkler
12570ecb00 Issue #254: The wildcard Mediatype */* is escaped now 2017-05-15 13:01:51 +02:00
Eugeniy Lykov
7b68aecbd7 Improve russian translation (#251)
* Improve russian translation

* Improve russian translation

Complete translation and correct errors.
2017-05-15 08:45:39 +02:00
Robert Winkler
7ce62a8a3d Updated version to 1.3.2-SNAPSHOT 2017-03-20 12:33:14 +01:00
43 changed files with 815 additions and 129 deletions

1
.gitignore vendored
View File

@@ -6,3 +6,4 @@ build
/.classpath
/.project
/.settings/
/out/

View File

@@ -27,7 +27,7 @@ image::src/docs/asciidoc/images/Swagger2Markup.PNG[]
image::src/docs/asciidoc/images/Swagger2Markup_definitions.PNG[]
== Reference documentation
- http://swagger2markup.github.io/swagger2markup/1.3.0/[Reference Documentation]
- http://swagger2markup.github.io/swagger2markup/1.3.1/[Reference Documentation]
- https://github.com/Swagger2Markup/swagger2markup/blob/master/RELEASENOTES.adoc[Release notes]
- https://github.com/Swagger2Markup/spring-swagger2markup-demo[Demo using Swagger2Markup, Spring Boot, Springfox and spring-restdocs]

View File

@@ -13,7 +13,7 @@ buildscript {
}
}
description = 'swagger2markup Build'
version = '1.3.1'
version = '1.3.2-SNAPSHOT'
ext.releaseVersion = '1.3.1'
group = 'io.github.swagger2markup'

View File

@@ -0,0 +1,14 @@
package io.github.swagger2markup;
/**
* swagger2markup (c) Duco Hosting
* Created by cas on 02-Oct-17.
*/
public enum ExampleType {
QUERY,
POST,
HEADER,
PATH,
BODY,
OTHER
}

View File

@@ -58,6 +58,9 @@ public class Labels {
public static final String HOST = "host";
public static final String BASE_PATH = "base_path";
public static final String SCHEMES = "schemes";
public static final String EXTERNAL_DOCS = "external_docs";
public static final String EXTERNAL_DOCS_DESC = "external_docs_desc";
public static final String EXTERNAL_DOCS_URL = "external_docs_url";
//Security Document
public static final String SECURITY = "security";

View File

@@ -17,14 +17,12 @@
package io.github.swagger2markup.builder;
import com.google.common.collect.Ordering;
import io.github.swagger2markup.*;
import io.github.swagger2markup.markup.builder.LineSeparator;
import io.github.swagger2markup.markup.builder.MarkupLanguage;
import io.github.swagger2markup.model.PathOperation;
import io.swagger.models.HttpMethod;
import io.swagger.models.parameters.Parameter;
import org.apache.commons.configuration2.*;
import org.apache.commons.configuration2.builder.fluent.Configurations;
import org.apache.commons.configuration2.convert.DefaultListDelimiterHandler;
@@ -111,12 +109,12 @@ public class Swagger2MarkupConfigBuilder {
Optional<Pattern> headerPattern = swagger2MarkupProperties.getHeaderPattern(HEADER_REGEX);
config.headerPattern = headerPattern.orElse(null);
config.listDelimiterEnabled = swagger2MarkupProperties.getBoolean(LIST_DELIMITER_ENABLED, false);
config.listDelimiter = swagger2MarkupProperties.getString(LIST_DELIMITER, ",").charAt(0);
if (config.listDelimiterEnabled && configuration instanceof AbstractConfiguration) {
((AbstractConfiguration)configuration).setListDelimiterHandler(new DefaultListDelimiterHandler(config.listDelimiter));
((AbstractConfiguration) configuration).setListDelimiterHandler(new DefaultListDelimiterHandler(config.listDelimiter));
}
Configuration swagger2markupConfiguration = compositeConfiguration.subset(PROPERTIES_PREFIX);
@@ -218,19 +216,20 @@ public class Swagger2MarkupConfigBuilder {
config.separatedOperationsEnabled = true;
return this;
}
/**
* Allows properties to contain a list of elements delimited by a specified character.
*
* @return this builder
*/
public Swagger2MarkupConfigBuilder withListDelimiter() {
config.listDelimiterEnabled = true;
return this;
}
/**
* Specifies the list delimiter which should be used.
*
*
* @param delimiter the delimiter
* @return this builder
*/
@@ -763,7 +762,7 @@ public class Swagger2MarkupConfigBuilder {
public Character getListDelimiter() {
return listDelimiter;
}
@Override
public boolean isListDelimiterEnabled() {
return listDelimiterEnabled;

View File

@@ -0,0 +1,72 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.Swagger2MarkupConverter;
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
import io.github.swagger2markup.spi.MarkupComponent;
import io.swagger.models.ExternalDocs;
import org.apache.commons.lang3.Validate;
import static io.github.swagger2markup.Labels.EXTERNAL_DOCS;
import static io.github.swagger2markup.Labels.EXTERNAL_DOCS_DESC;
import static io.github.swagger2markup.Labels.EXTERNAL_DOCS_URL;
import static io.github.swagger2markup.internal.utils.MarkupDocBuilderUtils.copyMarkupDocBuilder;
import static org.apache.commons.lang3.StringUtils.isNotBlank;
public class ExternalDocsComponent extends MarkupComponent<ExternalDocsComponent.Parameters> {
public ExternalDocsComponent(Swagger2MarkupConverter.Context context) {
super(context);
}
public static ExternalDocsComponent.Parameters parameters(ExternalDocs externalDocs, int titleLevel) {
return new ExternalDocsComponent.Parameters(externalDocs, titleLevel);
}
@Override
public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) {
ExternalDocs externalDocs = params.externalDocs;
String description = externalDocs.getDescription();
String url = externalDocs.getUrl();
if ((description != null && (isNotBlank(description) || (url != null && isNotBlank(url))))) {
markupDocBuilder.sectionTitleLevel(params.titleLevel, labels.getLabel(EXTERNAL_DOCS));
MarkupDocBuilder paragraph = copyMarkupDocBuilder(markupDocBuilder);
if (isNotBlank(description)) {
paragraph.italicText(labels.getLabel(EXTERNAL_DOCS_DESC)).textLine(COLON + description);
}
if (isNotBlank(url)) {
paragraph.italicText(labels.getLabel(EXTERNAL_DOCS_URL)).textLine(COLON + url);
}
markupDocBuilder.paragraph(paragraph.toString(), true);
}
return markupDocBuilder;
}
public static class Parameters {
private final int titleLevel;
private final ExternalDocs externalDocs;
public Parameters(ExternalDocs externalDocs,
int titleLevel) {
this.externalDocs = Validate.notNull(externalDocs, "ExternalDocs must not be null");
this.titleLevel = titleLevel;
}
}
}

View File

@@ -345,15 +345,17 @@ public class PathOperationComponent extends MarkupComponent<PathOperationCompone
* @param operation the Swagger Operation
*/
private void buildExamplesSection(MarkupDocBuilder markupDocBuilder, PathOperation operation, List<PageBreakLocations> locations) {
// Generate examples
Map<String, Object> generatedRequestExampleMap = ExamplesUtil.generateRequestExampleMap(config.isGeneratedExamplesEnabled(), operation, definitions, definitionDocumentResolver, markupDocBuilder);
Map<String, Object> generatedResponseExampleMap = ExamplesUtil.generateResponseExampleMap(config.isGeneratedExamplesEnabled(), operation, definitions, definitionDocumentResolver, markupDocBuilder);
// Get page break settings
boolean beforeExampleRequestBreak = locations.contains(BEFORE_OPERATION_EXAMPLE_REQUEST);
boolean afterExampleRequestBreak = locations.contains(AFTER_OPERATION_EXAMPLE_REQUEST);
boolean beforeExampleResponseBreak = locations.contains(BEFORE_OPERATION_EXAMPLE_RESPONSE);
boolean afterExampleResponseBreak = locations.contains(AFTER_OPERATION_EXAMPLE_RESPONSE);
// Write examples
exampleMap(markupDocBuilder, generatedRequestExampleMap, labels.getLabel(EXAMPLE_REQUEST), labels.getLabel(REQUEST), beforeExampleRequestBreak, afterExampleRequestBreak);
exampleMap(markupDocBuilder, generatedResponseExampleMap, labels.getLabel(EXAMPLE_RESPONSE), labels.getLabel(RESPONSE), beforeExampleResponseBreak, afterExampleResponseBreak);
}
@@ -373,7 +375,6 @@ public class PathOperationComponent extends MarkupComponent<PathOperationCompone
Iterator<Map.Entry<String, JsonNode>> fieldsIterator = rootNode.fields();
if (!fieldsIterator.hasNext()) {
// rootNode contains a single example, no need to further iterate.
String example = Json.pretty(rootNode);
@@ -407,6 +408,10 @@ public class PathOperationComponent extends MarkupComponent<PathOperationCompone
} else if (entry.getKey().equals("path")) {
// Path shouldn't have quotes around it
markupDocBuilder.listingBlock(entry.getValue().toString());
} else if (entry.getKey().equals("query")) {
//TODO issue #264: print query parameters in table
// markupDocBuilder.listingBlock(entry.getValue().toString());
logger.debug("Skipping query parameter: " + entry.getValue().toString());
} else {
markupDocBuilder.listingBlock(Json.pretty(entry.getValue()), "json");
}

View File

@@ -21,6 +21,7 @@ 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.ObjectType;
import io.github.swagger2markup.internal.type.RefType;
import io.github.swagger2markup.internal.type.Type;
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
import io.github.swagger2markup.spi.MarkupComponent;
@@ -56,30 +57,30 @@ public class PropertiesTableComponent extends MarkupComponent<PropertiesTableCom
* @param definitionDocumentResolver definition document resolver to apply to property type cross-reference
*/
PropertiesTableComponent(Swagger2MarkupConverter.Context context,
DocumentResolver definitionDocumentResolver) {
DocumentResolver definitionDocumentResolver) {
super(context);
this.definitionDocumentResolver = definitionDocumentResolver;
this.tableComponent = new TableComponent(context);
}
public static PropertiesTableComponent.Parameters parameters(Map<String, Property> properties,
String parameterName,
List<ObjectType> inlineDefinitions) {
String parameterName,
List<ObjectType> inlineDefinitions) {
return new PropertiesTableComponent.Parameters(properties, parameterName, inlineDefinitions);
}
public MarkupDocBuilder apply(MarkupDocBuilder markupDocBuilder, Parameters params) {
//TODO: This method is too complex, split it up in smaller methods to increase readability
StringColumn.Builder nameColumnBuilder = StringColumn.builder(ColumnIds.StringColumnId.of(labels.getLabel(NAME_COLUMN)))
.putMetaData(TableComponent.WIDTH_RATIO, "3");
.putMetaData(TableComponent.WIDTH_RATIO, "3");
StringColumn.Builder descriptionColumnBuilder = StringColumn.builder(ColumnIds.StringColumnId.of(labels.getLabel(DESCRIPTION_COLUMN)))
.putMetaData(TableComponent.WIDTH_RATIO, "11")
.putMetaData(TableComponent.HEADER_COLUMN, "true");
.putMetaData(TableComponent.WIDTH_RATIO, "11")
.putMetaData(TableComponent.HEADER_COLUMN, "true");
StringColumn.Builder schemaColumnBuilder = StringColumn.builder(ColumnIds.StringColumnId.of(labels.getLabel(SCHEMA_COLUMN)))
.putMetaData(TableComponent.WIDTH_RATIO, "4")
.putMetaData(TableComponent.HEADER_COLUMN, "true");
.putMetaData(TableComponent.WIDTH_RATIO, "4")
.putMetaData(TableComponent.HEADER_COLUMN, "true");
Map<String, Property> properties = params.properties;
if (MapUtils.isNotEmpty(properties)) {
@@ -166,7 +167,7 @@ public class PropertiesTableComponent extends MarkupComponent<PropertiesTableCom
}
DecimalFormat numberFormatter = new DecimalFormat("#.##",
DecimalFormatSymbols.getInstance(config.getOutputLanguage().toLocale()));
DecimalFormatSymbols.getInstance(config.getOutputLanguage().toLocale()));
if (optionalMinValue.isPresent()) {
if (isNotBlank(descriptionContent.toString())) {
@@ -188,7 +189,12 @@ public class PropertiesTableComponent extends MarkupComponent<PropertiesTableCom
if (isNotBlank(description) || optionalDefaultValue.isPresent()) {
descriptionContent.newLine(true);
}
descriptionContent.boldText(labels.getLabel(EXAMPLE_COLUMN)).text(COLON).literalText(Json.pretty(optionalExample.get()));
if(propertyType instanceof RefType && isReferenceLink(optionalExample.get().toString())) {
descriptionContent.boldText(labels.getLabel(EXAMPLE_COLUMN)).text(COLON).crossReference(optionalExample.get().toString());
} else {
descriptionContent.boldText(labels.getLabel(EXAMPLE_COLUMN)).text(COLON).literalText(Json.pretty(optionalExample.get()));
}
}
nameColumnBuilder.add(propertyNameContent.toString());
@@ -198,9 +204,19 @@ public class PropertiesTableComponent extends MarkupComponent<PropertiesTableCom
}
return tableComponent.apply(markupDocBuilder, TableComponent.parameters(
nameColumnBuilder.build(),
descriptionColumnBuilder.build(),
schemaColumnBuilder.build()));
nameColumnBuilder.build(),
descriptionColumnBuilder.build(),
schemaColumnBuilder.build()));
}
/*
* Check if a string is a link to a reference, format <<_referenceClass>>
*
* @param possibleAnchor String to check
* @return true if the string is a link to an anchor, false otherwise
*/
private boolean isReferenceLink(String possibleAnchor) {
return possibleAnchor.startsWith("<<_") && possibleAnchor.endsWith(">>");
}
public static class Parameters {
@@ -209,8 +225,8 @@ public class PropertiesTableComponent extends MarkupComponent<PropertiesTableCom
private final List<ObjectType> inlineDefinitions;
public Parameters(Map<String, Property> properties,
String parameterName,
List<ObjectType> inlineDefinitions) {
String parameterName,
List<ObjectType> inlineDefinitions) {
this.properties = Validate.notNull(properties, "Properties must not be null");
this.parameterName = Validate.notBlank(parameterName, "ParameterName must not be blank");

View File

@@ -20,10 +20,7 @@ import io.github.swagger2markup.Swagger2MarkupConverter;
import io.github.swagger2markup.internal.component.*;
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
import io.github.swagger2markup.spi.MarkupComponent;
import io.swagger.models.Contact;
import io.swagger.models.Info;
import io.swagger.models.Swagger;
import io.swagger.models.Tag;
import io.swagger.models.*;
import org.apache.commons.lang3.Validate;
import java.util.List;
@@ -45,6 +42,7 @@ public class OverviewDocument extends MarkupComponent<OverviewDocument.Parameter
private final TagsComponent tagsComponent;
private final ProducesComponent producesComponent;
private final ConsumesComponent consumesComponent;
private final ExternalDocsComponent externalDocsComponent;
public OverviewDocument(Swagger2MarkupConverter.Context context) {
super(context);
@@ -55,6 +53,7 @@ public class OverviewDocument extends MarkupComponent<OverviewDocument.Parameter
tagsComponent = new TagsComponent(context);
producesComponent = new ProducesComponent(context);
consumesComponent = new ConsumesComponent(context);
externalDocsComponent = new ExternalDocsComponent((context));
}
public static OverviewDocument.Parameters parameters(Swagger swagger) {
@@ -82,6 +81,7 @@ public class OverviewDocument extends MarkupComponent<OverviewDocument.Parameter
buildTagsSection(markupDocBuilder, swagger.getTags());
buildConsumesSection(markupDocBuilder, swagger.getConsumes());
buildProducesSection(markupDocBuilder, swagger.getProduces());
buildExternalDocsSection(markupDocBuilder, swagger.getExternalDocs());
applyOverviewDocumentExtension(new Context(Position.DOCUMENT_END, markupDocBuilder));
applyOverviewDocumentExtension(new Context(Position.DOCUMENT_AFTER, markupDocBuilder));
return markupDocBuilder;
@@ -141,6 +141,12 @@ public class OverviewDocument extends MarkupComponent<OverviewDocument.Parameter
}
}
private void buildExternalDocsSection(MarkupDocBuilder markupDocBuilder, ExternalDocs externalDocs) {
if (externalDocs != null) {
externalDocsComponent.apply(markupDocBuilder, ExternalDocsComponent.parameters(externalDocs, SECTION_TITLE_LEVEL));
}
}
/**
* Apply extension context to all OverviewContentExtension
*

View File

@@ -0,0 +1,25 @@
package io.github.swagger2markup.internal.utils;
import io.github.swagger2markup.ExampleType;
/**
* swagger2markup (c) Duco Hosting
* Created by cas on 02-Oct-17.
*/
public class Example {
private ExampleType type;
private Object example;
public Example(ExampleType type, Object example) {
this.type = type;
this.example = example;
}
public ExampleType getType() {
return type;
}
public Object getExample() {
return example;
}
}

View File

@@ -100,62 +100,10 @@ public class ExamplesUtil {
for (Parameter parameter : parameters) {
Object example = null;
if (parameter instanceof BodyParameter) {
example = ((BodyParameter) parameter).getExamples();
if (example == null) {
Model schema = ((BodyParameter) parameter).getSchema();
if (schema instanceof RefModel) {
String simpleRef = ((RefModel) schema).getSimpleRef();
example = generateExampleForRefModel(generateMissingExamples, simpleRef, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
} else if (generateMissingExamples) {
if (schema instanceof ComposedModel) {
//FIXME: getProperties() may throw NullPointerException
example = exampleMapForProperties(((ObjectType) ModelUtils.getType(schema, definitions, definitionDocumentResolver)).getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
} else if (schema instanceof ArrayModel) {
example = generateExampleForArrayModel((ArrayModel) schema, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
} else {
example = schema.getExample();
if (example == null) {
example = exampleMapForProperties(schema.getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
}
}
}
}
example = generateBodyParameterExample(parameter, generateMissingExamples, definitions, definitionDocumentResolver, markupDocBuilder);
} else if (parameter instanceof AbstractSerializableParameter) {
if (generateMissingExamples) {
Object abstractSerializableParameterExample;
abstractSerializableParameterExample = ((AbstractSerializableParameter) parameter).getExample();
if (abstractSerializableParameterExample == null) {
abstractSerializableParameterExample = parameter.getVendorExtensions().get("x-example");
}
if (abstractSerializableParameterExample == null) {
Property item = ((AbstractSerializableParameter) parameter).getItems();
if (item != null) {
abstractSerializableParameterExample = item.getExample();
if (abstractSerializableParameterExample == null) {
abstractSerializableParameterExample = PropertyAdapter.generateExample(item, markupDocBuilder);
}
}
if (abstractSerializableParameterExample == null) {
abstractSerializableParameterExample = ParameterAdapter.generateExample((AbstractSerializableParameter) parameter);
}
}
if (parameter instanceof PathParameter) {
String pathExample = (String) examples.get("path");
pathExample = pathExample.replace('{' + parameter.getName() + '}', String.valueOf(abstractSerializableParameterExample));
example = 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;
}
example = generateAbstractSerializableParameterExample(parameter, examples, markupDocBuilder);
}
} else if (parameter instanceof RefParameter) {
String simpleRef = ((RefParameter) parameter).getSimpleRef();
@@ -169,6 +117,81 @@ public class ExamplesUtil {
return examples;
}
/**
* Generates example for a body parameter
*
* @param parameter Body paramteter to generate example for
* @param generateMissingExamples Should an example be generated if none is defined
* @param definitions the map of definitions
* @param definitionDocumentResolver definitions document resolver
* @param markupDocBuilder the markup builder
* @return Object containing example
*/
private static Object generateBodyParameterExample(Parameter parameter, Boolean generateMissingExamples, Map<String, Model> definitions, DocumentResolver definitionDocumentResolver, MarkupDocBuilder markupDocBuilder) {
Object example = ((BodyParameter) parameter).getExamples();
if (example == null) {
Model schema = ((BodyParameter) parameter).getSchema();
if (schema instanceof RefModel) {
String simpleRef = ((RefModel) schema).getSimpleRef();
example = generateExampleForRefModel(generateMissingExamples, simpleRef, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
} else if (generateMissingExamples) {
if (schema instanceof ComposedModel) {
//FIXME: getProperties() may throw NullPointerException
example = exampleMapForProperties(((ObjectType) ModelUtils.getType(schema, definitions, definitionDocumentResolver)).getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
} else if (schema instanceof ArrayModel) {
example = generateExampleForArrayModel((ArrayModel) schema, definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
} else {
example = schema.getExample();
if (example == null) {
example = exampleMapForProperties(schema.getProperties(), definitions, definitionDocumentResolver, markupDocBuilder, new HashMap<>());
}
}
}
}
return example;
}
private static Object generateAbstractSerializableParameterExample(Parameter parameter, Map<String, Object> examples, MarkupDocBuilder markupDocBuilder) {
Object abstractSerializableParameterExample;
Object example;
abstractSerializableParameterExample = ((AbstractSerializableParameter) parameter).getExample();
if (abstractSerializableParameterExample == null) {
abstractSerializableParameterExample = parameter.getVendorExtensions().get("x-example");
}
if (abstractSerializableParameterExample == null) {
Property item = ((AbstractSerializableParameter) parameter).getItems();
if (item != null) {
abstractSerializableParameterExample = item.getExample();
if (abstractSerializableParameterExample == null) {
abstractSerializableParameterExample = PropertyAdapter.generateExample(item, markupDocBuilder);
}
}
if (abstractSerializableParameterExample == null) {
abstractSerializableParameterExample = ParameterAdapter.generateExample((AbstractSerializableParameter) parameter);
}
}
if (parameter instanceof PathParameter) {
String pathExample = (String) examples.get("path");
pathExample = pathExample.replace('{' + parameter.getName() + '}', String.valueOf(abstractSerializableParameterExample));
example = pathExample;
} else {
example = abstractSerializableParameterExample;
}
if (parameter instanceof QueryParameter) {
//TODO: #264 query parameters seem to be collected here
//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;
}
return example;
}
/**
* Generates an example object from a simple reference
*

View File

@@ -31,21 +31,28 @@ public class MarkupDocBuilderUtils {
if (StringUtils.isBlank(text)) {
return StringUtils.EMPTY;
}
return copyMarkupDocBuilder(markupDocBuilder).literalText(text).toString();
return copyMarkupDocBuilder(markupDocBuilder).literalText(escapeText(text)).toString();
}
private static String escapeText(String text) {
if(text.startsWith("*")){
text = "\\" + text;
}
return text;
}
public static String boldText(MarkupDocBuilder markupDocBuilder, String text) {
if (StringUtils.isBlank(text)) {
return StringUtils.EMPTY;
}
return copyMarkupDocBuilder(markupDocBuilder).boldText(text).toString();
return copyMarkupDocBuilder(markupDocBuilder).boldText(escapeText(text)).toString();
}
public static String italicText(MarkupDocBuilder markupDocBuilder, String text) {
if (StringUtils.isBlank(text)) {
return StringUtils.EMPTY;
}
return copyMarkupDocBuilder(markupDocBuilder).italicText(text).toString();
return copyMarkupDocBuilder(markupDocBuilder).italicText(escapeText(text)).toString();
}
public static String crossReference(MarkupDocBuilder markupDocBuilder, String document, String anchor, String text) {

View File

@@ -30,7 +30,7 @@ contact_information=Kontaktinformationen
contact_name=Kontakt
contact_email=Kontakt E-Mail
license_information=Lizenzinformationen
license=Linzenz
license=Lizenz
license_url=Lizenz-URL
terms_of_service=Nutzungsbedingungen
uri_scheme=URI Schema
@@ -64,3 +64,6 @@ polymorphism.column=Polymorphism
polymorphism.discriminator=Discriminator
polymorphism.nature.INHERITANCE=Inheritance
polymorphism.nature.COMPOSITION=Composition
external_docs=Externe Doku
external_docs_desc=Beschreibung
external_docs_url=URL

View File

@@ -63,4 +63,7 @@ operation.deprecated=This operation is deprecated.
polymorphism.column=Polymorphism
polymorphism.discriminator=Discriminator
polymorphism.nature.INHERITANCE=Inheritance
polymorphism.nature.COMPOSITION=Composition
polymorphism.nature.COMPOSITION=Composition
external_docs=External Docs
external_docs_desc=Description
external_docs_url=URL

View File

@@ -63,4 +63,7 @@ operation.deprecated=Operaci\u00F3n obsoleta
polymorphism.column=Polimorfismo
polymorphism.discriminator=Discriminador
polymorphism.nature.INHERITANCE=Herencia
polymorphism.nature.COMPOSITION=Composici\u00F3n
polymorphism.nature.COMPOSITION=Composici\u00F3n
external_docs=External Docs
external_docs_desc=Description
external_docs_url=URL

View File

@@ -63,4 +63,7 @@ operation.deprecated=Cette op\u00E9ration est obsol\u00E8te.
polymorphism.column=Polymorphisme
polymorphism.discriminator=Discriminateur
polymorphism.nature.INHERITANCE=H\u00E9ritage
polymorphism.nature.COMPOSITION=Composition
polymorphism.nature.COMPOSITION=Composition
external_docs=External Docs
external_docs_desc=Description
external_docs_url=URL

View File

@@ -64,3 +64,6 @@ polymorphism.column=\u30dd\u30ea\u30e2\u30fc\u30d5\u30a3\u30ba\u30e0
polymorphism.discriminator=Discriminator
polymorphism.nature.INHERITANCE=\u7d99\u627f
polymorphism.nature.COMPOSITION=\u5305\u542b
external_docs=External Docs
external_docs_desc=Description
external_docs_url=URL

View File

@@ -63,4 +63,7 @@ operation.deprecated=Essa opera\u00e7\u00e3o est\u00e1 obsoleta.
polymorphism.column=Polimorfismo
polymorphism.discriminator=Discriminador
polymorphism.nature.INHERITANCE=Heran\u00e7a
polymorphism.nature.COMPOSITION=Composi\u00e7\u00e3o
polymorphism.nature.COMPOSITION=Composi\u00e7\u00e3o
external_docs=External Docs
external_docs_desc=Description
external_docs_url=URL

View File

@@ -1,35 +1,35 @@
definitions=\u041E\u043F\u0440\u0435\u0434\u0435\u043B\u0435\u043D\u0438\u044F
default_column=\u041F\u043E \u0443\u043C\u043E\u043B\u0447\u0430\u043D\u0438\u044E
# validators
minlength_column=Minimum length
maxlength_column=Maximal length
length_column=Length
pattern_column=Pattern
minvalue_column=Minimum value
minvalue_exclusive_column=Minimum value (exclusive)
maxvalue_column=Maximum value
maxvalue_exclusive_column=Maximum value (exclusive)
flags.column=Flags
minlength_column=\u041C\u0438\u043D\u0438\u043C\u0430\u043B\u044C\u043D\u0430\u044F \u0434\u043B\u0438\u043D\u0430
maxlength_column=\u041C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u0430\u044F \u0434\u043B\u0438\u043D\u0430
length_column=\u0414\u043B\u0438\u043D\u0430
pattern_column=\u0428\u0430\u0431\u043B\u043E\u043D
minvalue_column=\u041C\u0438\u043D\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435
minvalue_exclusive_column=\u041C\u0438\u043D\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 (\u0438\u0441\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435)
maxvalue_column=\u041C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435
maxvalue_exclusive_column=\u041C\u0430\u043A\u0441\u0438\u043C\u0430\u043B\u044C\u043D\u043E\u0435 \u0437\u043D\u0430\u0447\u0435\u043D\u0438\u0435 (\u0438\u0441\u043A\u043B\u044E\u0447\u0435\u043D\u0438\u0435)
flags.column=\u0424\u043B\u0430\u0433\u0438
flags.required=\u041E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E
flags.optional=Optional
flags.read_only=Read-only
flags.read_write=Read-write
flags.optional=\u041D\u0435\u043E\u0431\u044F\u0437\u0430\u0442\u0435\u043B\u044C\u043D\u043E
flags.read_only=\u0422\u043E\u043B\u044C\u043A\u043E \u0434\u043B\u044F \u0447\u0442\u0435\u043D\u0438\u044F
flags.read_write=\u0427\u0442\u0435\u043D\u0438\u0435 \u0438 \u0437\u0430\u043F\u0438\u0441\u044C
example_column=\u041F\u0440\u0438\u043C\u0435\u0440
schema_column=\u0421\u0445\u0435\u043C\u0430
name_column=\u0418\u043C\u044F
description_column=\u041E\u043F\u0438\u0441\u0430\u043D\u0438\u0435
headers_column=Headers
headers_column=\u0417\u0430\u0433\u043E\u043B\u043E\u0432\u043A\u0438
scopes_column=\u041E\u0431\u043B\u0430\u0441\u0442\u0438 \u043F\u0440\u0438\u043C\u0435\u043D\u0435\u043D\u0438\u044F
produces=\u0412\u043E\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442
consumes=\u041F\u0440\u0438\u043D\u0438\u043C\u0430\u0435\u0442
tags=\u0422\u044D\u0433\u0438
tags=\u0422\u0435\u0433\u0438
overview=\u041E\u0431\u0437\u043E\u0440
current_version=\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u0432\u0435\u0440\u0441\u0438\u0438
version=\u0412\u0435\u0440\u0441\u0438\u044F
contact_information=\u041A\u043E\u043D\u0442\u0430\u043A\u0442\u043D\u0430\u044F \u0438\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F
contact_name=\u041A\u043E\u043D\u0442\u0430\u043A\u0442
contact_email=Email \u043A\u043E\u043D\u0442\u0430\u043A\u0442\u0430
license_information=\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u043B\u0438\u0446\u0435\u043D\u0446\u0438\u0438
contact_email=E-mail \u043A\u043E\u043D\u0442\u0430\u043A\u0442\u0430
license_information=\u0418\u043D\u0444\u043E\u0440\u043C\u0430\u0446\u0438\u044F \u043E \u043B\u0438\u0446\u0435\u043D\u0437\u0438\u0438
license=\u041B\u0438\u0446\u0435\u043D\u0437\u0438\u044F
license_url=URL \u043B\u0438\u0446\u0435\u043D\u0437\u0438\u0438
terms_of_service=\u0423\u0441\u043B\u043E\u0432\u0438\u044F \u0438\u0441\u043F\u043E\u043B\u044C\u0437\u043E\u0432\u0430\u043D\u0438\u044F
@@ -45,7 +45,7 @@ security_authorizationUrl=URL \u0430\u0432\u0442\u043E\u0440\u0438\u0437\u0430\u
security_tokenUrl=URL \u0442\u043E\u043A\u0435\u043D\u0430
paths=\u041F\u0443\u0442\u0438
resources=\u0420\u0435\u0441\u0443\u0440\u0441\u044B
operations=\u043E\u043F\u0435\u0440\u0430\u0446\u0438\u0438
operations=\u041E\u043F\u0435\u0440\u0430\u0446\u0438\u0438
security=\u0411\u0435\u0437\u043E\u043F\u0430\u0441\u043D\u043E\u0441\u0442\u044C
response=\u041E\u0442\u0432\u0435\u0442
request=\u0417\u0430\u043F\u0440\u043E\u0441
@@ -53,14 +53,17 @@ parameters=\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B
body_parameter=\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440 \u0442\u0435\u043B\u0430 \u0437\u0430\u043F\u0440\u043E\u0441\u0430
responses=\u041E\u0442\u0432\u0435\u0442\u044B
example_request=\u041F\u0440\u0438\u043C\u0435\u0440 HTTP \u0437\u0430\u043F\u0440\u043E\u0441\u0430
example_response=\u041F\u0440\u0438\u043C\u0435\u0440 HTTP \u0437\u0430\u043F\u0440\u043E\u0441\u0430
example_response=\u041F\u0440\u0438\u043C\u0435\u0440 HTTP \u043E\u0442\u0432\u0435\u0442\u0430
type_column=\u0422\u0438\u043F
http_code_column=HTTP \u043A\u043E\u0434
parameter=\u041F\u0430\u0440\u0430\u043C\u0435\u0442\u0440
unknown=Unknown
unknown=\u041D\u0435\u0438\u0437\u0432\u0435\u0441\u0442\u043D\u044B\u0439
no_content=\u0411\u0435\u0437 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u043C\u043E\u0433\u043E
operation.deprecated=\u042D\u0442\u0430 \u043E\u043F\u0435\u0440\u0430\u0446\u0438\u044F \u0443\u0441\u0442\u0430\u0440\u0435\u043B\u0430.
polymorphism.column=Polymorphism
polymorphism.discriminator=Discriminator
polymorphism.nature.INHERITANCE=Inheritance
polymorphism.nature.COMPOSITION=Composition
polymorphism.column=\u041F\u043E\u043B\u0438\u043C\u043E\u0440\u0444\u0438\u0437\u043C
polymorphism.discriminator=\u0414\u0438\u0441\u043A\u0440\u0438\u043C\u0438\u043D\u0430\u0442\u043E\u0440
polymorphism.nature.INHERITANCE=\u041D\u0430\u0441\u043B\u0435\u0434\u043E\u0432\u0430\u043D\u0438\u0435
polymorphism.nature.COMPOSITION=\u0421\u0442\u0440\u0443\u043A\u0442\u0443\u0440\u0430
external_docs=External Docs
external_docs_desc=Description
external_docs_url=URL

View File

@@ -63,4 +63,7 @@ operation.deprecated=Bu i\u015Flem \u00F6nerilmemektedir.
polymorphism.column=\u00C7okbi\u00E7imlilik
polymorphism.discriminator=Ayr\u0131\u015Ft\u0131r\u0131c\u0131
polymorphism.nature.INHERITANCE=Kal\u0131t\u0131m
polymorphism.nature.COMPOSITION=Birle\u015Ftirme
polymorphism.nature.COMPOSITION=Birle\u015Ftirme
external_docs=External Docs
external_docs_desc=Description
external_docs_url=URL

View File

@@ -64,3 +64,6 @@ polymorphism.column=\u591a\u6001\u6027
polymorphism.discriminator=\u9274\u522b
polymorphism.nature.INHERITANCE=\u7ee7\u627f
polymorphism.nature.COMPOSITION=\u6210\u5206
external_docs=External Docs
external_docs_desc=Description
external_docs_url=URL

View File

@@ -782,4 +782,29 @@ public class AsciidocConverterTest {
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected/asciidoc/page_breaks").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "testWithPageBreaks.html");
}
@Test
public void testWithQueryParameters() throws IOException, URISyntaxException {
//Given
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_query_params.yaml").toURI());
Path outputDirectory = Paths.get("build/test/asciidoc/query_params");
FileUtils.deleteQuietly(outputDirectory.toFile());
//When
Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder()
.withGeneratedExamples()
.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/query_params").toURI());
DiffUtils.assertThatAllFilesAreEqual(expectedFilesDirectory, outputDirectory, "textWithQueryParameters.html");
}
}

View File

@@ -0,0 +1,68 @@
/*
* Copyright 2017 Robert Winkler
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.github.swagger2markup.internal.component;
import io.github.swagger2markup.Swagger2MarkupConverter;
import io.github.swagger2markup.assertions.DiffUtils;
import io.github.swagger2markup.internal.document.OverviewDocument;
import io.github.swagger2markup.markup.builder.MarkupDocBuilder;
import io.swagger.models.ExternalDocs;
import io.swagger.models.Swagger;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.nio.file.Paths;
public class ExternalDocsComponentTest extends AbstractComponentTest {
private static final String COMPONENT_NAME = "external_docs";
private Path outputDirectory;
@Before
public void setUp() {
outputDirectory = getOutputFile(COMPONENT_NAME);
FileUtils.deleteQuietly(outputDirectory.toFile());
}
@Test
public void testExternalDocsComponent() throws URISyntaxException {
//Given
Path file = Paths.get(DefinitionComponentTest.class.getResource("/yaml/swagger_petstore_20160612.yaml").toURI());
Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
Swagger swagger = converter.getContext().getSwagger();
ExternalDocs externalDocs = swagger.getExternalDocs();
Assert.assertNotNull(externalDocs);
Swagger2MarkupConverter.Context context = converter.getContext();
MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();
//When
markupDocBuilder = new ExternalDocsComponent(context).apply(markupDocBuilder, ExternalDocsComponent.parameters(externalDocs, OverviewDocument.SECTION_TITLE_LEVEL));
markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);
//Then
Path expectedFile = getExpectedFile(COMPONENT_NAME);
DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));
}
}

View File

@@ -0,0 +1,8 @@
=== External Docs
[%hardbreaks]
__Description__ : Find out more about Swagger
__URL__ : http://swagger.io

View File

@@ -83,7 +83,7 @@ Test description
|===
|Name|Description|Schema
|**category** +
__optional__|**Example** : `"<<_category>>"`|<<_category,Category>>
__optional__|**Example** : <<_category>>|<<_category,Category>>
|**id** +
__optional__|**Example** : `0`|integer (int64)
|**name** +

View File

@@ -51,7 +51,7 @@ __optional__|State value|enum (ADDED, REMOVED, CHANGED)
==== Produces
* `*/*`
* `\*/*`

View File

@@ -83,7 +83,7 @@ Test description
|===
|Name|Description|Schema
|**category** +
__optional__|**Example** : `"<<_category>>"`|<<_category,Category>>
__optional__|**Example** : <<_category>>|<<_category,Category>>
|**id** +
__optional__|**Example** : `0`|integer (int64)
|**name** +

View File

@@ -41,4 +41,10 @@ __Schemes__ : HTTP
* user : User resource
=== External Docs
[%hardbreaks]
__Description__ : Find out more about Swagger
__URL__ : http://swagger.io

View File

@@ -41,4 +41,10 @@ __Schemes__ : HTTP
* user : User resource
=== External Docs
[%hardbreaks]
__Description__ : Find out more about Swagger
__URL__ : http://swagger.io

View File

@@ -39,7 +39,7 @@ __optional__|String metrics|< string, integer (int32) > map
==== Produces
* `*/*`
* `\*/*`
==== Tags
@@ -84,7 +84,7 @@ __optional__|Mappings|< string, <<_mappinginfo,MappingInfo>> > map
==== Produces
* `*/*`
* `\*/*`
==== Tags
@@ -153,7 +153,7 @@ __optional__|string
==== Produces
* `*/*`
* `\*/*`
==== Tags
@@ -198,7 +198,7 @@ __optional__|String metrics|< string, string > map
==== Produces
* `*/*`
* `\*/*`
==== Tags

View File

@@ -29,7 +29,7 @@ Get collections
==== Produces
* `*/*`
* `\*/*`
[[_getpets]]
@@ -59,7 +59,7 @@ Get pets
==== Produces
* `*/*`
* `\*/*`

View File

@@ -29,7 +29,7 @@ Get collections
==== Produces
* `*/*`
* `\*/*`
[[_getpets]]
@@ -59,7 +59,7 @@ Get pets
==== Produces
* `*/*`
* `\*/*`

View File

@@ -0,0 +1,53 @@
[[_definitions]]
== Definitions
[[_category]]
=== Category
[options="header", cols=".^3,.^11,.^4"]
|===
|Name|Description|Schema
|**id** +
__optional__|**Example** : `0`|integer (int64)
|**name** +
__optional__|**Example** : `"string"`|string
|===
[[_pet]]
=== Pet
[options="header", cols=".^3,.^11,.^4"]
|===
|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=".^3,.^11,.^4"]
|===
|Name|Description|Schema
|**id** +
__optional__|**Example** : `0`|integer (int64)
|**name** +
__optional__|**Example** : `"string"`|string
|===

View File

@@ -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

View File

@@ -0,0 +1,91 @@
[[_paths]]
== Paths
[[_findpetsbystatus]]
=== Finds Pets by status
....
GET /pet/findByStatus
....
==== Description
Multiple status values can be provided with comma separated strings
==== Parameters
[options="header", cols=".^2,.^3,.^9,.^4"]
|===
|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=".^2,.^14,.^4"]
|===
|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=".^3,.^4,.^13"]
|===
|Type|Name|Scopes
|**oauth2**|**<<_petstore_auth,petstore_auth>>**|write:pets,read:pets
|===
==== Example HTTP request
===== Request path
----
/pet/findByStatus
----
===== Request query
|===
|Name|Value
|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"
} ]
----

View File

@@ -0,0 +1,26 @@
[[_securityscheme]]
== Security
[[_petstore_auth]]
=== petstore_auth
[%hardbreaks]
__Type__ : oauth2
__Flow__ : implicit
__Token URL__ : http://petstore.swagger.io/oauth/dialog
[options="header", cols=".^3,.^17"]
|===
|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

View File

@@ -41,6 +41,12 @@ __Schemes__ : HTTP
* user : User resource
=== External Docs
[%hardbreaks]
__Description__ : Find out more about Swagger
__URL__ : http://swagger.io
[[_paths]]

View File

@@ -41,4 +41,10 @@ __Schemes__ : HTTP
* user : User resource
=== External Docs
[%hardbreaks]
__Description__ : Find out more about Swagger
__URL__ : http://swagger.io

View File

@@ -37,4 +37,9 @@ For this sample, you can use the api key `special-key` to test the authorization
* user : User resource
### External Docs
*Description* : Find out more about Swagger
*URL* : http://swagger.io

View File

@@ -37,4 +37,9 @@ For this sample, you can use the api key `special-key` to test the authorization
* user : User resource
### External Docs
*Description* : Find out more about Swagger
*URL* : http://swagger.io

View File

@@ -670,3 +670,7 @@ definitions:
- Cancelled
complete:
type: boolean
externalDocs:
description: "Find out more about Swagger"
url: "http://swagger.io"

View File

@@ -0,0 +1,139 @@
# See issue swagger2markup#264 and #266
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"
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"