Moved classes from 'io.github.robwin.swagger2markup' to 'io.github.swagger2markup'
This commit is contained in:
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup;
|
||||
package io.github.swagger2markup;
|
||||
|
||||
public enum GroupBy {
|
||||
AS_IS,
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup;
|
||||
package io.github.swagger2markup;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup;
|
||||
package io.github.swagger2markup;
|
||||
|
||||
public enum OrderBy {
|
||||
AS_IS,
|
||||
@@ -13,14 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup;
|
||||
package io.github.swagger2markup;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.Ordering;
|
||||
import io.github.robwin.markup.builder.LineSeparator;
|
||||
import io.github.robwin.markup.builder.MarkupLanguage;
|
||||
import io.github.robwin.swagger2markup.internal.model.PathOperation;
|
||||
import io.github.robwin.swagger2markup.internal.utils.IOUtils;
|
||||
import io.github.swagger2markup.internal.model.PathOperation;
|
||||
import io.github.swagger2markup.utils.IOUtils;
|
||||
import io.swagger.models.HttpMethod;
|
||||
import io.swagger.models.parameters.Parameter;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
@@ -93,8 +93,8 @@ public class Swagger2MarkupConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Automatically set default path for external content files based on specified {@code swaggerLocation}.<br/>
|
||||
* If {@code swaggerLocation} is null, default path can't be set and features are disabled.<br/>
|
||||
* Automatically set default path for external content files based on specified {@code swaggerLocation}.<br>
|
||||
* If {@code swaggerLocation} is null, default path can't be set and features are disabled.<br>
|
||||
* Paths have to be explicitly set when swaggerLocation.scheme != 'file' to limit the number of URL requests.
|
||||
*
|
||||
* @param swaggerLocation base path to set default paths
|
||||
@@ -428,7 +428,7 @@ public class Swagger2MarkupConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Include hand-written descriptions into the Paths document.<br/>
|
||||
* Include hand-written descriptions into the Paths document.<br>
|
||||
* Use default URI.
|
||||
*
|
||||
* @return this builder
|
||||
@@ -463,7 +463,7 @@ public class Swagger2MarkupConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Include hand-written descriptions into the Definitions document.<br/>
|
||||
* Include hand-written descriptions into the Definitions document.<br>
|
||||
* Use default URI.
|
||||
*
|
||||
* @return this builder
|
||||
@@ -532,8 +532,8 @@ public class Swagger2MarkupConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies tag ordering.<br/>
|
||||
* By default tag ordering == {@link io.github.robwin.swagger2markup.OrderBy#NATURAL}.<br/>
|
||||
* Specifies tag ordering.<br>
|
||||
* By default tag ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
||||
* Use {@link #withTagOrdering(Comparator)} to set a custom ordering.
|
||||
*
|
||||
* @param orderBy tag ordering
|
||||
@@ -560,8 +560,8 @@ public class Swagger2MarkupConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies operation ordering.<br/>
|
||||
* By default operation ordering == {@link io.github.robwin.swagger2markup.OrderBy#AS_IS}.<br/>
|
||||
* Specifies operation ordering.<br>
|
||||
* By default operation ordering == {@link io.github.swagger2markup.OrderBy#AS_IS}.<br>
|
||||
* Use {@link #withOperationOrdering(Comparator)} to set a custom ordering.
|
||||
*
|
||||
* @param orderBy operation ordering
|
||||
@@ -588,8 +588,8 @@ public class Swagger2MarkupConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies definition ordering.<br/>
|
||||
* By default definition ordering == {@link io.github.robwin.swagger2markup.OrderBy#NATURAL}.<br/>
|
||||
* Specifies definition ordering.<br>
|
||||
* By default definition ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
||||
* Use {@link #withDefinitionOrdering(Comparator)} to set a custom ordering.
|
||||
*
|
||||
* @param orderBy definition ordering
|
||||
@@ -616,8 +616,8 @@ public class Swagger2MarkupConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies parameter ordering.<br/>
|
||||
* By default parameter ordering == {@link io.github.robwin.swagger2markup.OrderBy#NATURAL}.<br/>
|
||||
* Specifies parameter ordering.<br>
|
||||
* By default parameter ordering == {@link OrderBy#NATURAL}.<br>
|
||||
* Use {@link #withParameterOrdering(Comparator)} to set a custom ordering.
|
||||
*
|
||||
* @param orderBy parameter ordering
|
||||
@@ -645,8 +645,8 @@ public class Swagger2MarkupConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies property ordering.<br/>
|
||||
* By default property ordering == {@link io.github.robwin.swagger2markup.OrderBy#NATURAL}.<br/>
|
||||
* Specifies property ordering.<br>
|
||||
* By default property ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
||||
* Use {@link #withPropertyOrdering(Comparator)} to set a custom ordering.
|
||||
*
|
||||
* @param orderBy property ordering
|
||||
@@ -674,8 +674,8 @@ public class Swagger2MarkupConfig {
|
||||
}
|
||||
|
||||
/**
|
||||
* Specifies response ordering.<br/>
|
||||
* By default response ordering == {@link io.github.robwin.swagger2markup.OrderBy#NATURAL}.<br/>
|
||||
* Specifies response ordering.<br>
|
||||
* By default response ordering == {@link io.github.swagger2markup.OrderBy#NATURAL}.<br>
|
||||
* Use {@link #withResponseOrdering(Comparator)} to set a custom ordering.
|
||||
*
|
||||
* @param orderBy response ordering
|
||||
@@ -13,15 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup;
|
||||
package io.github.swagger2markup;
|
||||
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import io.github.robwin.swagger2markup.internal.document.builder.DefinitionsDocumentBuilder;
|
||||
import io.github.robwin.swagger2markup.internal.document.builder.OverviewDocumentBuilder;
|
||||
import io.github.robwin.swagger2markup.internal.document.builder.PathsDocumentBuilder;
|
||||
import io.github.robwin.swagger2markup.internal.document.builder.SecurityDocumentBuilder;
|
||||
import io.github.robwin.swagger2markup.spi.Extension;
|
||||
import io.github.robwin.swagger2markup.spi.SwaggerModelExtension;
|
||||
import io.github.swagger2markup.internal.document.builder.DefinitionsDocumentBuilder;
|
||||
import io.github.swagger2markup.internal.document.builder.OverviewDocumentBuilder;
|
||||
import io.github.swagger2markup.internal.document.builder.PathsDocumentBuilder;
|
||||
import io.github.swagger2markup.internal.document.builder.SecurityDocumentBuilder;
|
||||
import io.github.swagger2markup.spi.Extension;
|
||||
import io.github.swagger2markup.spi.SwaggerModelExtension;
|
||||
import io.swagger.models.Swagger;
|
||||
import io.swagger.parser.SwaggerParser;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
@@ -14,15 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup;
|
||||
package io.github.swagger2markup;
|
||||
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.DynamicDefinitionsDocumentExtension;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.DynamicPathsDocumentExtension;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.DynamicOverviewDocumentExtension;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.DynamicSecurityDocumentExtension;
|
||||
import io.github.robwin.swagger2markup.spi.*;
|
||||
import io.github.swagger2markup.spi.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
@@ -59,12 +55,6 @@ public class Swagger2MarkupExtensionRegistry {
|
||||
|
||||
Builder(boolean useDefaults) {
|
||||
extensions = MultimapBuilder.hashKeys().arrayListValues().build();
|
||||
if (useDefaults) {
|
||||
withExtension(new DynamicOverviewDocumentExtension());
|
||||
withExtension(new DynamicSecurityDocumentExtension());
|
||||
withExtension(new DynamicPathsDocumentExtension());
|
||||
withExtension(new DynamicDefinitionsDocumentExtension());
|
||||
}
|
||||
}
|
||||
|
||||
public Swagger2MarkupExtensionRegistry build() {
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.document;
|
||||
package io.github.swagger2markup.internal.document;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
|
||||
@@ -13,16 +13,16 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.document.builder;
|
||||
package io.github.swagger2markup.internal.document.builder;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
import io.github.robwin.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.robwin.swagger2markup.internal.document.MarkupDocument;
|
||||
import io.github.robwin.swagger2markup.spi.DefinitionsDocumentExtension;
|
||||
import io.github.robwin.swagger2markup.internal.type.ObjectType;
|
||||
import io.github.robwin.swagger2markup.internal.type.Type;
|
||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.swagger2markup.internal.document.MarkupDocument;
|
||||
import io.github.swagger2markup.spi.DefinitionsDocumentExtension;
|
||||
import io.github.swagger2markup.internal.type.ObjectType;
|
||||
import io.github.swagger2markup.internal.type.Type;
|
||||
import io.swagger.models.ComposedModel;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.RefModel;
|
||||
@@ -42,11 +42,11 @@ import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
import static io.github.robwin.swagger2markup.internal.utils.IOUtils.normalizeName;
|
||||
import static io.github.robwin.swagger2markup.spi.DefinitionsDocumentExtension.*;
|
||||
import static io.github.swagger2markup.utils.IOUtils.normalizeName;
|
||||
import static io.github.swagger2markup.spi.DefinitionsDocumentExtension.*;
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
import static io.github.robwin.swagger2markup.internal.utils.MapUtils.toKeySet;
|
||||
import static io.github.swagger2markup.internal.utils.MapUtils.toKeySet;
|
||||
|
||||
/**
|
||||
* @author Robert Winkler
|
||||
@@ -328,7 +328,7 @@ public class DefinitionsDocumentBuilder extends MarkupDocumentBuilder {
|
||||
for (String fileNameExtension : config.getMarkupLanguage().getFileNameExtensions()) {
|
||||
URI contentUri = config.getDefinitionDescriptionsUri().resolve(descriptionFolder).resolve(descriptionFileName + fileNameExtension);
|
||||
|
||||
try (Reader reader = io.github.robwin.swagger2markup.internal.utils.IOUtils.uriReader(contentUri)) {
|
||||
try (Reader reader = io.github.swagger2markup.utils.IOUtils.uriReader(contentUri)) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Definition description content processed {}", contentUri);
|
||||
}
|
||||
@@ -13,21 +13,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.document.builder;
|
||||
package io.github.swagger2markup.internal.document.builder;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilders;
|
||||
import io.github.robwin.markup.builder.MarkupLanguage;
|
||||
import io.github.robwin.markup.builder.MarkupTableColumn;
|
||||
import io.github.robwin.swagger2markup.Swagger2MarkupConfig;
|
||||
import io.github.robwin.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.robwin.swagger2markup.internal.document.MarkupDocument;
|
||||
import io.github.robwin.swagger2markup.internal.type.DefinitionDocumentResolver;
|
||||
import io.github.robwin.swagger2markup.internal.type.ObjectType;
|
||||
import io.github.robwin.swagger2markup.internal.type.RefType;
|
||||
import io.github.robwin.swagger2markup.internal.type.Type;
|
||||
import io.github.robwin.swagger2markup.internal.utils.IOUtils;
|
||||
import io.github.robwin.swagger2markup.internal.utils.PropertyUtils;
|
||||
import io.github.swagger2markup.Swagger2MarkupConfig;
|
||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.swagger2markup.internal.document.MarkupDocument;
|
||||
import io.github.swagger2markup.internal.type.DefinitionDocumentResolver;
|
||||
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.utils.IOUtils;
|
||||
import io.github.swagger2markup.internal.utils.PropertyUtils;
|
||||
import io.swagger.models.properties.Property;
|
||||
import io.swagger.util.Json;
|
||||
import org.apache.commons.collections4.MapUtils;
|
||||
@@ -39,7 +39,7 @@ import java.io.IOException;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
import static io.github.robwin.swagger2markup.internal.utils.MapUtils.toKeySet;
|
||||
import static io.github.swagger2markup.internal.utils.MapUtils.toKeySet;
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.document.builder;
|
||||
package io.github.swagger2markup.internal.document.builder;
|
||||
|
||||
import io.github.robwin.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.robwin.swagger2markup.internal.document.MarkupDocument;
|
||||
import io.github.robwin.swagger2markup.spi.OverviewDocumentExtension;
|
||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.swagger2markup.internal.document.MarkupDocument;
|
||||
import io.github.swagger2markup.spi.OverviewDocumentExtension;
|
||||
import io.swagger.models.*;
|
||||
|
||||
import java.nio.file.Path;
|
||||
@@ -25,7 +25,7 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
import static io.github.robwin.swagger2markup.spi.OverviewDocumentExtension.*;
|
||||
import static io.github.swagger2markup.spi.OverviewDocumentExtension.*;
|
||||
import static org.apache.commons.collections4.CollectionUtils.isNotEmpty;
|
||||
import static org.apache.commons.lang3.StringUtils.*;
|
||||
|
||||
@@ -13,21 +13,24 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.document.builder;
|
||||
package io.github.swagger2markup.internal.document.builder;
|
||||
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Multimap;
|
||||
import io.github.robwin.markup.builder.*;
|
||||
import io.github.robwin.swagger2markup.GroupBy;
|
||||
import io.github.robwin.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.robwin.swagger2markup.internal.document.MarkupDocument;
|
||||
import io.github.robwin.swagger2markup.internal.model.PathOperation;
|
||||
import io.github.robwin.swagger2markup.internal.type.ObjectType;
|
||||
import io.github.robwin.swagger2markup.internal.type.RefType;
|
||||
import io.github.robwin.swagger2markup.internal.type.Type;
|
||||
import io.github.robwin.swagger2markup.internal.utils.*;
|
||||
import io.github.robwin.swagger2markup.spi.PathsDocumentExtension;
|
||||
import io.github.swagger2markup.GroupBy;
|
||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.swagger2markup.internal.document.MarkupDocument;
|
||||
import io.github.swagger2markup.internal.model.PathOperation;
|
||||
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.internal.utils.ExamplesUtil;
|
||||
import io.github.swagger2markup.internal.utils.ParameterUtils;
|
||||
import io.github.swagger2markup.internal.utils.PropertyUtils;
|
||||
import io.github.swagger2markup.internal.utils.TagUtils;
|
||||
import io.github.swagger2markup.spi.PathsDocumentExtension;
|
||||
import io.swagger.models.*;
|
||||
import io.swagger.models.auth.SecuritySchemeDefinition;
|
||||
import io.swagger.models.parameters.Parameter;
|
||||
@@ -47,12 +50,13 @@ import java.net.URI;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.*;
|
||||
|
||||
import static io.github.robwin.swagger2markup.internal.utils.IOUtils.normalizeName;
|
||||
import static io.github.robwin.swagger2markup.internal.utils.ListUtils.*;
|
||||
import static io.github.robwin.swagger2markup.internal.utils.MapUtils.toKeySet;
|
||||
import static io.github.robwin.swagger2markup.internal.utils.TagUtils.convertTagsListToMap;
|
||||
import static io.github.robwin.swagger2markup.internal.utils.TagUtils.getTagDescription;
|
||||
import static io.github.robwin.swagger2markup.spi.PathsDocumentExtension.*;
|
||||
import static io.github.swagger2markup.utils.IOUtils.normalizeName;
|
||||
import static io.github.swagger2markup.internal.utils.ListUtils.toSet;
|
||||
import static io.github.swagger2markup.internal.utils.MapUtils.toKeySet;
|
||||
import static io.github.swagger2markup.internal.utils.TagUtils.convertTagsListToMap;
|
||||
import static io.github.swagger2markup.internal.utils.TagUtils.getTagDescription;
|
||||
import static io.github.swagger2markup.spi.PathsDocumentExtension.Context;
|
||||
import static io.github.swagger2markup.spi.PathsDocumentExtension.Position;
|
||||
import static org.apache.commons.lang3.StringUtils.defaultString;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
@@ -675,7 +679,7 @@ public class PathsDocumentBuilder extends MarkupDocumentBuilder {
|
||||
for (String fileNameExtension : config.getMarkupLanguage().getFileNameExtensions()) {
|
||||
URI contentUri = config.getOperationDescriptionsUri().resolve(descriptionFolder).resolve(descriptionFileName + fileNameExtension);
|
||||
|
||||
try (Reader reader = io.github.robwin.swagger2markup.internal.utils.IOUtils.uriReader(contentUri)) {
|
||||
try (Reader reader = io.github.swagger2markup.utils.IOUtils.uriReader(contentUri)) {
|
||||
if (logger.isInfoEnabled()) {
|
||||
logger.info("Operation description content processed {}", contentUri);
|
||||
}
|
||||
@@ -804,7 +808,7 @@ public class PathsDocumentBuilder extends MarkupDocumentBuilder {
|
||||
String defaultResolver = super.apply(definitionName);
|
||||
|
||||
if (defaultResolver != null && config.isSeparatedOperationsEnabled())
|
||||
return defaultString(config.getInterDocumentCrossReferencesPrefix()) + new File("..", defaultResolver).getPath();
|
||||
return defaultString(config.getInterDocumentCrossReferencesPrefix()) + new File("src/main", defaultResolver).getPath();
|
||||
else
|
||||
return defaultResolver;
|
||||
}
|
||||
@@ -13,13 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.document.builder;
|
||||
package io.github.swagger2markup.internal.document.builder;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
import io.github.robwin.markup.builder.MarkupTableColumn;
|
||||
import io.github.robwin.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.robwin.swagger2markup.internal.document.MarkupDocument;
|
||||
import io.github.robwin.swagger2markup.spi.SecurityDocumentExtension;
|
||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.swagger2markup.internal.document.MarkupDocument;
|
||||
import io.github.swagger2markup.spi.SecurityDocumentExtension;
|
||||
import io.swagger.models.auth.ApiKeyAuthDefinition;
|
||||
import io.swagger.models.auth.OAuth2Definition;
|
||||
import io.swagger.models.auth.SecuritySchemeDefinition;
|
||||
@@ -28,8 +28,8 @@ import org.apache.commons.collections4.MapUtils;
|
||||
import java.nio.file.Path;
|
||||
import java.util.*;
|
||||
|
||||
import static io.github.robwin.swagger2markup.spi.SecurityDocumentExtension.Context;
|
||||
import static io.github.robwin.swagger2markup.spi.SecurityDocumentExtension.Position;
|
||||
import static io.github.swagger2markup.spi.SecurityDocumentExtension.Context;
|
||||
import static io.github.swagger2markup.spi.SecurityDocumentExtension.Position;
|
||||
import static org.apache.commons.lang3.StringUtils.isNotBlank;
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.internal.model;
|
||||
package io.github.swagger2markup.internal.model;
|
||||
|
||||
import io.swagger.models.HttpMethod;
|
||||
import io.swagger.models.Operation;
|
||||
@@ -54,7 +54,7 @@ public class PathOperation {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an unique id for the operation.<br/>
|
||||
* Returns an unique id for the operation.<br>
|
||||
* Use {@code <operation id>}, then {@code <operation path> lowercase(<operation method>)} if operation id is not set.
|
||||
*
|
||||
* @return operation unique id
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.internal.type;
|
||||
package io.github.swagger2markup.internal.type;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.internal.type;
|
||||
package io.github.swagger2markup.internal.type;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.internal.type;
|
||||
package io.github.swagger2markup.internal.type;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.internal.type;
|
||||
package io.github.swagger2markup.internal.type;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.internal.type;
|
||||
package io.github.swagger2markup.internal.type;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
import io.swagger.models.properties.Property;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.internal.type;
|
||||
package io.github.swagger2markup.internal.type;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.internal.type;
|
||||
package io.github.swagger2markup.internal.type;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
@@ -14,10 +14,10 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.internal.utils;
|
||||
package io.github.swagger2markup.internal.utils;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
import io.github.robwin.swagger2markup.internal.model.PathOperation;
|
||||
import io.github.swagger2markup.internal.model.PathOperation;
|
||||
import io.swagger.models.*;
|
||||
import io.swagger.models.parameters.*;
|
||||
import io.swagger.models.properties.ArrayProperty;
|
||||
@@ -39,7 +39,10 @@ public class ExamplesUtil {
|
||||
/**
|
||||
* Generates a Map of response examples
|
||||
*
|
||||
* @param generateMissingExamples specifies the missing examples should be generated
|
||||
* @param operation the Swagger Operation
|
||||
* @param definitions the map of definitions
|
||||
* @param markupDocBuilder the markup builder
|
||||
* @return map containing response examples.
|
||||
*/
|
||||
public static Map<String, Object> generateResponseExampleMap(boolean generateMissingExamples, Operation operation, Map<String, Model> definitions, MarkupDocBuilder markupDocBuilder) {
|
||||
@@ -74,7 +77,10 @@ public class ExamplesUtil {
|
||||
/**
|
||||
* Generates examples for request
|
||||
*
|
||||
* @param generateMissingExamples specifies the missing examples should be generated
|
||||
* @param pathOperation the Swagger Operation
|
||||
* @param definitions the map of definitions
|
||||
* @param markupDocBuilder the markup builder
|
||||
* @return an Optional with the example content
|
||||
*/
|
||||
public static Map<String, Object> generateRequestExampleMap(boolean generateMissingExamples, PathOperation pathOperation, Map<String, Model> definitions, MarkupDocBuilder markupDocBuilder) {
|
||||
@@ -157,7 +163,10 @@ public class ExamplesUtil {
|
||||
/**
|
||||
* Generates an example object from a simple reference
|
||||
*
|
||||
* @param generateMissingExamples specifies the missing examples should be generated
|
||||
* @param simpleRef the simple reference string
|
||||
* @param definitions the map of definitions
|
||||
* @param markupDocBuilder the markup builder
|
||||
* @return returns an Object or Map of examples
|
||||
*/
|
||||
public static Object generateExampleForRefModel(boolean generateMissingExamples, String simpleRef, Map<String, Model> definitions, MarkupDocBuilder markupDocBuilder) {
|
||||
@@ -205,7 +214,10 @@ public class ExamplesUtil {
|
||||
* Generates a map of examples from a map of properties. If defined examples are found, those are used. Otherwise,
|
||||
* examples are generated from the type.
|
||||
*
|
||||
* @param properties map of properties
|
||||
* @param properties the map of properties
|
||||
* @param definitions the map of definitions
|
||||
* @param markupDocBuilder the markup builder
|
||||
*
|
||||
* @return a Map of examples
|
||||
*/
|
||||
public static Map<String, Object> exampleMapForProperties(Map<String, Property> properties, Map<String, Model> definitions, MarkupDocBuilder markupDocBuilder) {
|
||||
@@ -266,6 +278,8 @@ public class ExamplesUtil {
|
||||
* Generates examples from an ArrayProperty
|
||||
*
|
||||
* @param value ArrayProperty
|
||||
* @param definitions map of definitions
|
||||
* @param markupDocBuilder the markup builder
|
||||
* @return array of Object
|
||||
*/
|
||||
public static Object[] generateExampleForArrayProperty(ArrayProperty value, Map<String, Model> definitions, MarkupDocBuilder markupDocBuilder) {
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.utils;
|
||||
package io.github.swagger2markup.internal.utils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.utils;
|
||||
package io.github.swagger2markup.internal.utils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -13,13 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.utils;
|
||||
package io.github.swagger2markup.internal.utils;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import io.github.robwin.swagger2markup.internal.type.ArrayType;
|
||||
import io.github.robwin.swagger2markup.internal.type.ObjectType;
|
||||
import io.github.robwin.swagger2markup.internal.type.RefType;
|
||||
import io.github.robwin.swagger2markup.internal.type.Type;
|
||||
import io.github.swagger2markup.internal.type.ArrayType;
|
||||
import io.github.swagger2markup.internal.type.ObjectType;
|
||||
import io.github.swagger2markup.internal.type.RefType;
|
||||
import io.github.swagger2markup.internal.type.Type;
|
||||
import io.swagger.models.ArrayModel;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.ModelImpl;
|
||||
@@ -32,6 +32,7 @@ public final class ModelUtils {
|
||||
* Retrieves the type of a model, or otherwise null
|
||||
*
|
||||
* @param model the model
|
||||
* @param definitionDocumentResolver the definition document resolver
|
||||
* @return the type of the model, or otherwise null
|
||||
*/
|
||||
public static Type getType(Model model, Function<String, String> definitionDocumentResolver) {
|
||||
@@ -13,11 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.utils;
|
||||
package io.github.swagger2markup.internal.utils;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
import io.github.robwin.swagger2markup.internal.type.*;
|
||||
import io.github.swagger2markup.internal.type.*;
|
||||
import io.swagger.models.Model;
|
||||
import io.swagger.models.parameters.AbstractSerializableParameter;
|
||||
import io.swagger.models.parameters.BodyParameter;
|
||||
@@ -37,6 +37,7 @@ public final class ParameterUtils {
|
||||
* Retrieves the type of a parameter, or otherwise null
|
||||
*
|
||||
* @param parameter the parameter
|
||||
* @param definitionDocumentResolver the defintion document resolver
|
||||
* @return the type of the parameter, or otherwise null
|
||||
*/
|
||||
public static Type getType(Parameter parameter, Function<String, String> definitionDocumentResolver){
|
||||
@@ -13,11 +13,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.utils;
|
||||
package io.github.swagger2markup.internal.utils;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
import io.github.robwin.swagger2markup.internal.type.*;
|
||||
import io.github.swagger2markup.internal.type.*;
|
||||
import io.swagger.models.properties.*;
|
||||
import io.swagger.models.refs.RefFormat;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
@@ -33,6 +33,7 @@ public final class PropertyUtils {
|
||||
* Retrieves the type and format of a property.
|
||||
*
|
||||
* @param property the property
|
||||
* @param definitionDocumentResolver the definition document resolver
|
||||
* @return the type of the property
|
||||
*/
|
||||
public static Type getType(Property property, Function<String, String> definitionDocumentResolver) {
|
||||
@@ -105,6 +106,7 @@ public final class PropertyUtils {
|
||||
/**
|
||||
* Return example display string for the given {@code property}.
|
||||
*
|
||||
* @param generateMissingExamples specifies if missing examples should be generated
|
||||
* @param property property
|
||||
* @param markupDocBuilder doc builder
|
||||
* @return property example display string
|
||||
@@ -13,13 +13,13 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.internal.utils;
|
||||
package io.github.swagger2markup.internal.utils;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.google.common.collect.MultimapBuilder;
|
||||
import com.google.common.collect.Ordering;
|
||||
import io.github.robwin.swagger2markup.internal.model.PathOperation;
|
||||
import io.github.swagger2markup.internal.model.PathOperation;
|
||||
import io.swagger.models.Tag;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.slf4j.Logger;
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.spi;
|
||||
package io.github.swagger2markup.spi;
|
||||
|
||||
import io.github.robwin.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
||||
|
||||
/**
|
||||
* An abstract extension which must be extended by an extension
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.spi;
|
||||
package io.github.swagger2markup.spi;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.spi;
|
||||
package io.github.swagger2markup.spi;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
@@ -14,9 +14,9 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.spi;
|
||||
package io.github.swagger2markup.spi;
|
||||
|
||||
import io.github.robwin.swagger2markup.Swagger2MarkupConverter;
|
||||
import io.github.swagger2markup.Swagger2MarkupConverter;
|
||||
|
||||
/**
|
||||
* A marker interface which must be implemented by an extension
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.spi;
|
||||
package io.github.swagger2markup.spi;
|
||||
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.spi;
|
||||
package io.github.swagger2markup.spi;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
import io.github.robwin.swagger2markup.GroupBy;
|
||||
import io.github.robwin.swagger2markup.internal.model.PathOperation;
|
||||
import io.github.swagger2markup.GroupBy;
|
||||
import io.github.swagger2markup.internal.model.PathOperation;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
/**
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.spi;
|
||||
package io.github.swagger2markup.spi;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import io.github.robwin.markup.builder.MarkupDocBuilder;
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.spi;
|
||||
package io.github.swagger2markup.spi;
|
||||
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package io.github.robwin.swagger2markup.internal.utils;
|
||||
package io.github.swagger2markup.utils;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
@@ -30,7 +30,7 @@ public class IOUtils {
|
||||
private static final Pattern NAME_FORBIDDEN_PATTERN = Pattern.compile("[^0-9A-Za-z-_]+");
|
||||
|
||||
/**
|
||||
* Create a normalized name from an arbitrary string.<br/>
|
||||
* Create a normalized name from an arbitrary string.<br>
|
||||
* Paths separators are replaced, so this function can't be applied on a whole path, but must be called on each path sections.
|
||||
*
|
||||
* @param name current name of the file
|
||||
@@ -45,12 +45,12 @@ public class IOUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a reader from specified {@code source}.<br/>
|
||||
* Create a reader from specified {@code source}.<br>
|
||||
* Returned reader should be explicitly closed after use.
|
||||
*
|
||||
* @param uri source URI
|
||||
* @return reader
|
||||
* @throws IOException
|
||||
* @throws IOException if the connection cannot be opened
|
||||
*/
|
||||
public static Reader uriReader(URI uri) throws IOException {
|
||||
return new BufferedReader(new InputStreamReader(uri.toURL().openStream(), StandardCharsets.UTF_8));
|
||||
@@ -62,6 +62,6 @@ public class IOUtils {
|
||||
* @return URI parent
|
||||
*/
|
||||
public static URI uriParent(URI uri) {
|
||||
return uri.getPath().endsWith("/") ? uri.resolve("..") : uri.resolve(".");
|
||||
return uri.getPath().endsWith("/") ? uri.resolve("src/main") : uri.resolve(".");
|
||||
}
|
||||
}
|
||||
@@ -1,88 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2016 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.robwin.swagger2markup.assertions;
|
||||
|
||||
|
||||
import com.sksamuel.diffpatch.DiffMatchPatch;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.util.LinkedList;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
public class DiffAssert extends AbstractAssert<DiffAssert, Path>{
|
||||
|
||||
public DiffAssert(Path actual) {
|
||||
super(actual, DiffAssert.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Verifies that the content of the actual File is equal to the given one.
|
||||
*
|
||||
* @param expected the given value to compare the actual value to.
|
||||
* @param reportPath the path to the report which should be generated if the files differ.
|
||||
* @return {@code this} assertion object.
|
||||
* @throws AssertionError if the actual value is not equal to the given one or if the actual value is {@code null}..
|
||||
*/
|
||||
public DiffAssert isEqualTo(Path expected, Path reportPath) {
|
||||
LinkedList<DiffMatchPatch.Diff> diffs = diff(actual, expected);
|
||||
boolean allDiffsAreEqual = assertThatAllDiffsAreEqual(diffs);
|
||||
if(!allDiffsAreEqual){
|
||||
writeHtmlReport(reportPath, diffs);
|
||||
}
|
||||
assertThat(allDiffsAreEqual).as("The content of the following files differ. Actual: %s, Expected %s. Check the HTML report for more details: %s", actual.toAbsolutePath(), expected.toAbsolutePath(), reportPath.toAbsolutePath()).isTrue();
|
||||
return myself;
|
||||
}
|
||||
|
||||
public boolean assertThatAllDiffsAreEqual(LinkedList<DiffMatchPatch.Diff> diffs){
|
||||
for(DiffMatchPatch.Diff diff : diffs){
|
||||
if(diff.operation == DiffMatchPatch.Operation.DELETE || diff.operation == DiffMatchPatch.Operation.INSERT){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private static LinkedList<DiffMatchPatch.Diff> diff(Path actual, Path expected){
|
||||
DiffMatchPatch differ = new DiffMatchPatch();
|
||||
try {
|
||||
return differ.diff_main(IOUtils.toString(expected.toUri()), IOUtils.toString(actual.toUri()), false);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException("Failed to diff files.", e);
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeHtmlReport(Path reportPath, LinkedList<DiffMatchPatch.Diff> diffs){
|
||||
DiffMatchPatch differ = new DiffMatchPatch();
|
||||
try {
|
||||
Files.createDirectories(reportPath.getParent());
|
||||
try (BufferedWriter writer = Files.newBufferedWriter(reportPath, Charset.forName("UTF-8"))) {
|
||||
writer.write(differ.diff_prettyHtml(diffs));
|
||||
}
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(String.format("Failed to write report %s", reportPath.toAbsolutePath()), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
*
|
||||
* Copyright 2016 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.robwin.swagger2markup.assertions;
|
||||
|
||||
import org.apache.commons.lang3.Validate;
|
||||
|
||||
import java.nio.file.Path;
|
||||
|
||||
/**
|
||||
* Entry point for assertion methods for diffing files.
|
||||
*
|
||||
* @author Robert Winkler
|
||||
*/
|
||||
public class DiffAssertions {
|
||||
|
||||
/**
|
||||
* Creates a new instance of <code>{@link DiffAssert}</code>.
|
||||
*
|
||||
* @param actual the the actual File path.
|
||||
* @return the created assertion object.
|
||||
*/
|
||||
|
||||
public static DiffAssert assertThat(Path actual) {
|
||||
Validate.notNull(actual, "actual must not be null");
|
||||
return new DiffAssert(actual);
|
||||
}
|
||||
}
|
||||
@@ -13,13 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup;
|
||||
package io.github.swagger2markup;
|
||||
|
||||
import io.github.robwin.swagger2markup.assertions.DiffUtils;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.DynamicDefinitionsDocumentExtension;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.DynamicPathsDocumentExtension;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.SchemaExtension;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.SpringRestDocsExtension;
|
||||
import io.github.swagger2markup.assertions.DiffUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.junit.Before;
|
||||
@@ -108,35 +104,6 @@ public class AsciidocConverterTest {
|
||||
DiffUtils.assertThatAllFilesAreEqual(outputDirectory, expectedFilesDirectory, "testSwagger2AsciiDocConversion.html");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwagger2AsciiDocConversionWithSpringRestDocsExtension() throws IOException, URISyntaxException {
|
||||
//Given
|
||||
String swaggerJsonString = IOUtils.toString(getClass().getResourceAsStream("/yaml/swagger_petstore.yaml"));
|
||||
Path outputDirectory = Paths.get("build/docs/asciidoc/spring_rest_docs");
|
||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
||||
|
||||
//When
|
||||
Swagger2MarkupExtensionRegistry registry = Swagger2MarkupExtensionRegistry.ofEmpty()
|
||||
.withExtension(new SpringRestDocsExtension(Paths.get("src/test/resources/docs/asciidoc/paths").toUri()).withDefaultSnippets())
|
||||
.build();
|
||||
|
||||
Swagger2MarkupConfig config = Swagger2MarkupConfig.ofDefaults()
|
||||
.build();
|
||||
|
||||
Swagger2MarkupConverter.from(swaggerJsonString)
|
||||
.withConfig(config)
|
||||
.withExtensionRegistry(registry)
|
||||
.build()
|
||||
.intoFolder(outputDirectory);
|
||||
|
||||
//Then
|
||||
String[] files = outputDirectory.toFile().list();
|
||||
assertThat(files).hasSize(4).containsAll(expectedFiles);
|
||||
|
||||
Path expectedFilesDirectory = Paths.get(AsciidocConverterTest.class.getResource("/expected_results/asciidoc/spring_rest_docs").toURI());
|
||||
DiffUtils.assertThatAllFilesAreEqual(outputDirectory, expectedFilesDirectory, "testSwagger2AsciiDocConversionWithSpringRestDocsExtension.html");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwagger2AsciiDocConversionWithExamples() throws IOException, URISyntaxException {
|
||||
//Given
|
||||
@@ -402,58 +369,4 @@ public class AsciidocConverterTest {
|
||||
assertThat(new String(Files.readAllBytes(outputDirectory.resolve("overview.adoc")), Charset.forName("UTF-8")))
|
||||
.contains("== Sch\u00E9ma d'URI");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwagger2AsciiDocExtensions() throws IOException, URISyntaxException {
|
||||
//Given
|
||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
||||
Path outputDirectory = Paths.get("build/docs/asciidoc/generated");
|
||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
||||
|
||||
//When
|
||||
Swagger2MarkupConfig config = Swagger2MarkupConfig.ofDefaults()
|
||||
.build();
|
||||
Swagger2MarkupExtensionRegistry registry = Swagger2MarkupExtensionRegistry.ofEmpty()
|
||||
.withExtension(new DynamicDefinitionsDocumentExtension(Paths.get("src/test/resources/docs/asciidoc/extensions")))
|
||||
.withExtension(new DynamicPathsDocumentExtension(Paths.get("src/test/resources/docs/asciidoc/extensions")))
|
||||
.build();
|
||||
Swagger2MarkupConverter.from(file)
|
||||
.withConfig(config)
|
||||
.withExtensionRegistry(registry)
|
||||
.build()
|
||||
.intoFolder(outputDirectory);
|
||||
|
||||
//Then
|
||||
assertThat(new String(Files.readAllBytes(outputDirectory.resolve("paths.adoc")))).contains(
|
||||
"Pet update request extension");
|
||||
assertThat(new String(Files.readAllBytes(outputDirectory.resolve("definitions.adoc")))).contains(
|
||||
"Pet extension");
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwagger2AsciiDocSchemaExtension() throws IOException, URISyntaxException {
|
||||
//Given
|
||||
Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
||||
Path outputDirectory = Paths.get("build/docs/asciidoc/generated");
|
||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
||||
|
||||
//When
|
||||
Swagger2MarkupConfig config = Swagger2MarkupConfig.ofDefaults()
|
||||
.build();
|
||||
Swagger2MarkupExtensionRegistry registry = Swagger2MarkupExtensionRegistry.ofEmpty()
|
||||
.withExtension(new SchemaExtension(Paths.get("src/test/resources/docs/asciidoc/extensions").toUri()))
|
||||
.build();
|
||||
Swagger2MarkupConverter.from(file)
|
||||
.withConfig(config)
|
||||
.withExtensionRegistry(registry)
|
||||
.build()
|
||||
.intoFolder(outputDirectory);
|
||||
|
||||
//Then
|
||||
assertThat(new String(Files.readAllBytes(outputDirectory.resolve("definitions.adoc")))).contains(
|
||||
"=== Pet");
|
||||
assertThat(new String(Files.readAllBytes(outputDirectory.resolve("definitions.adoc")))).contains(
|
||||
"==== XML Schema");
|
||||
}
|
||||
}
|
||||
@@ -13,8 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup;
|
||||
package io.github.swagger2markup;
|
||||
|
||||
import io.github.swagger2markup.utils.IOUtils;
|
||||
import io.swagger.models.Swagger;
|
||||
import org.junit.Test;
|
||||
|
||||
@@ -44,7 +45,7 @@ public class GeneralConverterTest {
|
||||
.build();
|
||||
|
||||
//Then
|
||||
URI baseUri = io.github.robwin.swagger2markup.internal.utils.IOUtils.uriParent(converter.getContext().getSwaggerLocation());
|
||||
URI baseUri = IOUtils.uriParent(converter.getContext().getSwaggerLocation());
|
||||
assertThat(converter.getContext().getConfig().getDefinitionDescriptionsUri()).isEqualTo(baseUri);
|
||||
assertThat(converter.getContext().getConfig().getOperationDescriptionsUri()).isEqualTo(baseUri);
|
||||
}
|
||||
@@ -13,16 +13,14 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup;
|
||||
package io.github.swagger2markup;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.common.collect.Maps;
|
||||
import com.google.common.collect.Sets;
|
||||
import io.github.robwin.markup.builder.MarkupLanguage;
|
||||
import io.github.robwin.swagger2markup.assertions.DiffUtils;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.DynamicDefinitionsDocumentExtension;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.DynamicPathsDocumentExtension;
|
||||
import io.github.swagger2markup.assertions.DiffUtils;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -164,35 +162,6 @@ public class MarkdownConverterTest {
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSwagger2MarkdownExtensions() throws IOException, URISyntaxException {
|
||||
//Given
|
||||
Path file = Paths.get(MarkdownConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
|
||||
Path outputDirectory = Paths.get("build/docs/markdown/generated");
|
||||
FileUtils.deleteQuietly(outputDirectory.toFile());
|
||||
|
||||
//When
|
||||
Swagger2MarkupConfig config = Swagger2MarkupConfig.ofDefaults()
|
||||
.withMarkupLanguage(MarkupLanguage.MARKDOWN)
|
||||
.build();
|
||||
Swagger2MarkupExtensionRegistry registry = Swagger2MarkupExtensionRegistry.ofEmpty()
|
||||
.withExtension(new DynamicDefinitionsDocumentExtension(Paths.get("src/test/resources/docs/markdown/extensions")))
|
||||
.withExtension(new DynamicPathsDocumentExtension(Paths.get("src/test/resources/docs/markdown/extensions")))
|
||||
.build();
|
||||
Swagger2MarkupConverter.from(file)
|
||||
.withConfig(config)
|
||||
.withExtensionRegistry(registry)
|
||||
.build()
|
||||
.intoFolder(outputDirectory);
|
||||
|
||||
//Then
|
||||
assertThat(new String(Files.readAllBytes(outputDirectory.resolve("paths.md")))).contains(
|
||||
"Pet update request extension");
|
||||
assertThat(new String(Files.readAllBytes(outputDirectory.resolve("definitions.md")))).contains(
|
||||
"Pet extension");
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* Given a markdown document to search, this checks to see if the specified tables
|
||||
* have all of the expected fields listed.
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup;
|
||||
package io.github.swagger2markup;
|
||||
|
||||
import com.google.common.collect.Ordering;
|
||||
import io.github.robwin.markup.builder.MarkupLanguage;
|
||||
@@ -16,8 +16,9 @@
|
||||
*
|
||||
*
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.assertions;
|
||||
package io.github.swagger2markup.assertions;
|
||||
|
||||
import io.github.robwin.diff.DiffAssertions;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.spi;
|
||||
package io.github.swagger2markup.spi;
|
||||
|
||||
import io.swagger.models.Swagger;
|
||||
|
||||
@@ -13,15 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package io.github.robwin.swagger2markup.spi;
|
||||
package io.github.swagger2markup.spi;
|
||||
|
||||
import io.github.robwin.swagger2markup.Swagger2MarkupExtensionRegistry;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.DynamicDefinitionsDocumentExtension;
|
||||
import io.github.robwin.swagger2markup.internal.extensions.DynamicPathsDocumentExtension;
|
||||
import io.github.swagger2markup.Swagger2MarkupExtensionRegistry;
|
||||
import io.swagger.models.Swagger;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.nio.file.Paths;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,8 +32,6 @@ public class Swagger2MarkupExtensionRegistryTest {
|
||||
Swagger2MarkupExtensionRegistry.Builder registryBuilder = Swagger2MarkupExtensionRegistry.ofDefaults();
|
||||
|
||||
registryBuilder.withExtension(new MySwaggerModelExtension());
|
||||
registryBuilder.withExtension(new DynamicDefinitionsDocumentExtension(Paths.get("src/test/resources/docs/asciidoc/extensions")));
|
||||
registryBuilder.withExtension(new DynamicPathsDocumentExtension(Paths.get("src/test/resources/docs/asciidoc/extensions")));
|
||||
|
||||
try {
|
||||
registryBuilder.withExtension(new AbstractExtension() {
|
||||
Reference in New Issue
Block a user