Java Code Examples for io.github.swagger2markup.markup.builder.MarkupDocBuilder#writeToFileWithoutExtension()

The following examples show how to use io.github.swagger2markup.markup.builder.MarkupDocBuilder#writeToFileWithoutExtension() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExternalDocsComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@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().getSchema();

 ExternalDocs externalDocs = swagger.getExternalDocs();
 Assert.assertNotNull(externalDocs);

 Swagger2MarkupConverter.SwaggerContext 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));

}
 
Example 2
Source File: ParameterTableComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testParameterTableComponent() throws URISyntaxException {
    //Given
    Path file = Paths.get(ParameterTableComponentTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
    Swagger swagger = converter.getContext().getSchema();

    io.swagger.models.Path path = swagger.getPaths().get("/pets");
    List<SwaggerPathOperation> pathOperations = PathUtils.toPathOperationsList("/pets", path);

    Swagger2MarkupConverter.SwaggerContext context = converter.getContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    //When
    markupDocBuilder = new ParameterTableComponent(context, new DefinitionDocumentResolverFromOperation(context))
            .apply(markupDocBuilder, ParameterTableComponent.parameters(pathOperations.get(0), new ArrayList<>(), 3));

    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    //Then
    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
Example 3
Source File: TagsComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testTagsComponent() throws URISyntaxException {
    List<Tag> tags = new ArrayList<>();
    tags.add(new Tag().name("Tag1").description("description"));
    tags.add(new Tag().name("Tag2"));

    Swagger2MarkupConverter.SwaggerContext context = createContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    markupDocBuilder = new TagsComponent(context).apply(markupDocBuilder, TagsComponent.parameters(tags, OverviewDocument.SECTION_TITLE_LEVEL));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
Example 4
Source File: PropertiesTableComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testPropertiesTableComponent() throws URISyntaxException {
    //Given
    Path file = Paths.get(PropertiesTableComponentTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
    Swagger swagger = converter.getContext().getSchema();

    Model petModel = swagger.getDefinitions().get("Pet");

    Swagger2MarkupConverter.SwaggerContext context = converter.getContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    List<ObjectType> localDefinitions = new ArrayList<>();
    //When
    markupDocBuilder = new PropertiesTableComponent(context,
            new DefinitionDocumentResolverFromDefinition(context))
            .apply(markupDocBuilder, PropertiesTableComponent.parameters(petModel.getProperties(),
                    "Pet", localDefinitions));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    //Then
    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
Example 5
Source File: LicenseInfoComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testLicenseInfoComponent() throws URISyntaxException {

    Info info = new Info()
            .license(new License().name("Apache 2.0").url("http://www.apache.org/licenses/LICENSE-2.0"))
            .termsOfService("Bla bla bla");

    Swagger2MarkupConverter.SwaggerContext context = createContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    markupDocBuilder = new LicenseInfoComponent(context).apply(markupDocBuilder, LicenseInfoComponent.parameters(info, OverviewDocument.SECTION_TITLE_LEVEL));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
Example 6
Source File: DefinitionsDocument.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
/**
 * Generate definition files depending on the generation mode
 *
 * @param definitionName definition name to process
 * @param model          definition model to process
 */
private void buildDefinition(MarkupDocBuilder markupDocBuilder, String definitionName, Model model) {
    if (logger.isDebugEnabled()) {
        logger.debug("Definition processed : '{}'", definitionName);
    }
    if (config.isSeparatedDefinitionsEnabled()) {
        MarkupDocBuilder defDocBuilder = copyMarkupDocBuilder(markupDocBuilder);
        applyDefinitionComponent(defDocBuilder, definitionName, model);
        Path definitionFile = context.getOutputPath().resolve(definitionDocumentNameResolver.apply(definitionName));
        defDocBuilder.writeToFileWithoutExtension(definitionFile, StandardCharsets.UTF_8);
        if (logger.isDebugEnabled()) {
            logger.debug("Separate definition file produced : '{}'", definitionFile);
        }

        definitionRef(markupDocBuilder, definitionName);

    } else {
        applyDefinitionComponent(markupDocBuilder, definitionName, model);
    }
}
 
Example 7
Source File: ProducesComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testProducesComponent() throws URISyntaxException {
    List<String> produces = new ArrayList<>();
    produces.add("application/json");
    produces.add("application/xml");

    Swagger2MarkupConverter.SwaggerContext context = createContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    markupDocBuilder = new ProducesComponent(context)
            .apply(markupDocBuilder, ProducesComponent.parameters(produces, OverviewDocument.SECTION_TITLE_LEVEL));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
Example 8
Source File: UriSchemeComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testUriSchemeComponent() throws URISyntaxException {

    Swagger swagger = new Swagger().host("http://localhost").basePath("/v2");
    swagger.addScheme(Scheme.HTTP);
    swagger.addScheme(Scheme.HTTPS);

    Swagger2MarkupConverter.SwaggerContext context = createContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    markupDocBuilder = new UriSchemeComponent(context).apply(markupDocBuilder, UriSchemeComponent.parameters(swagger, OverviewDocument.SECTION_TITLE_LEVEL));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
Example 9
Source File: ConsumesComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testConsumesComponent() throws URISyntaxException {
    List<String> consumes = new ArrayList<>();
    consumes.add("application/json");
    consumes.add("application/xml");

    Swagger2MarkupConverter.SwaggerContext context = createContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    markupDocBuilder = new ConsumesComponent(context).apply(markupDocBuilder, ConsumesComponent.parameters(
            consumes, OverviewDocument.SECTION_TITLE_LEVEL));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
Example 10
Source File: SecuritySchemeComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testSecuritySchemeComponent() throws URISyntaxException {
    //Given
    Path file = Paths.get(SecuritySchemeComponentTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
    Swagger swagger = converter.getContext().getSchema();

    List<SwaggerPathOperation> pathOperations = PathUtils.toPathOperationsList(swagger.getPaths(), "", "",
            converter.getContext().getConfig().getOperationOrdering());

    Swagger2MarkupConverter.SwaggerContext context = converter.getContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    //When
    markupDocBuilder = new SecuritySchemeComponent(context, new SecurityDocumentResolver(context))
            .apply(markupDocBuilder, SecuritySchemeComponent.parameters(pathOperations.get(0), 3));

    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    //Then
    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
Example 11
Source File: SecuritySchemeDefinitionComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testSecuritySchemeDefinitionComponentWithApiKey() throws URISyntaxException {
    //Given
    Path file = Paths.get(SecuritySchemeDefinitionComponentTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
    Swagger swagger = converter.getContext().getSchema();

    SecuritySchemeDefinition securitySchemeDefinition = swagger.getSecurityDefinitions().get("api_key");

    Swagger2MarkupConverter.SwaggerContext context = converter.getContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    markupDocBuilder = new SecuritySchemeDefinitionComponent(context).apply(
            markupDocBuilder, SecuritySchemeDefinitionComponent.parameters("api_key",
                    securitySchemeDefinition,
                    OverviewDocument.SECTION_TITLE_LEVEL));
    markupDocBuilder.writeToFileWithoutExtension(apiKeyOutputDirectory, StandardCharsets.UTF_8);

    Path expectedFile = getExpectedFile(API_KEY_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, apiKeyOutputDirectory, getReportName(API_KEY_NAME));

}
 
Example 12
Source File: TableComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testTable() throws URISyntaxException {
    StringColumn.Builder typeColumnBuilder = StringColumn.builder(StringColumnId.of("type"));
    typeColumnBuilder.add("type1").add("type2").add("type3");

    StringColumn.Builder nameColumnBuilder = StringColumn.builder(StringColumnId.of("name"));
    nameColumnBuilder.add("name1").add("").add("name3");

    StringColumn.Builder descriptionColumnBuilder = StringColumn.builder(StringColumnId.of("description"));
    descriptionColumnBuilder.add("").add("").add("");

    Swagger2MarkupConverter.SwaggerContext context = createContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    markupDocBuilder = new TableComponent(context).apply(markupDocBuilder,
            TableComponent.parameters(
                    typeColumnBuilder.build(),
                    nameColumnBuilder.build(),
                    descriptionColumnBuilder.build()));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));
}
 
Example 13
Source File: ResponsesComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testResponsesComponent() throws URISyntaxException {
    //Given
    Path file = Paths.get(ResponsesComponentTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
    Swagger swagger = converter.getContext().getSchema();

    io.swagger.models.Path path = swagger.getPaths().get("/pets/findByStatus");
    List<SwaggerPathOperation> pathOperations = PathUtils.toPathOperationsList("/pets/findByStatus", path);

    Swagger2MarkupConverter.SwaggerContext context = converter.getContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    //When
    markupDocBuilder = new ResponseComponent(context, new DefinitionDocumentResolverFromOperation(context))
            .apply(markupDocBuilder, ResponseComponent.parameters(pathOperations.get(0), 3, new ArrayList<>()));

    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    //Then
    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
Example 14
Source File: BodyParameterComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testBodyParameterComponent() throws URISyntaxException {
    //Given
    Path file = Paths.get(AsciidocConverterTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
    Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder().withFlatBody().build();
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).withConfig(config).build();
    Swagger swagger = converter.getContext().getSchema();

    io.swagger.models.Path path = swagger.getPaths().get("/pets");
    List<SwaggerPathOperation> pathOperations = PathUtils.toPathOperationsList("/pets", path);

    Swagger2MarkupConverter.SwaggerContext context = converter.getContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    //When
    markupDocBuilder = new BodyParameterComponent(converter.getContext(),
            new DefinitionDocumentResolverFromOperation(context))
            .apply(markupDocBuilder, BodyParameterComponent.parameters(pathOperations.get(0), new ArrayList<>()));

    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    //Then
    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
Example 15
Source File: PathsDocument.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
/**
 * Builds a path operation depending on generation mode.
 *
 * @param operation operation
 */
private void buildOperation(MarkupDocBuilder markupDocBuilder, SwaggerPathOperation operation, Swagger2MarkupConfig config) {
    if (config.isSeparatedOperationsEnabled()) {
        MarkupDocBuilder pathDocBuilder = copyMarkupDocBuilder(markupDocBuilder);
        applyPathOperationComponent(pathDocBuilder, operation);
        java.nio.file.Path operationFile = context.getOutputPath().resolve(operationDocumentNameResolver.apply(operation));
        pathDocBuilder.writeToFileWithoutExtension(operationFile, StandardCharsets.UTF_8);
        if (logger.isDebugEnabled()) {
            logger.debug("Separate operation file produced : '{}'", operationFile);
        }
        buildOperationRef(markupDocBuilder, operation);

    } else {
        applyPathOperationComponent(markupDocBuilder, operation);
    }

    if (logger.isDebugEnabled()) {
        logger.debug("Operation processed : '{}' (normalized id = '{}')", operation, normalizeName(operation.getId()));
    }
}
 
Example 16
Source File: PathOperationComponentTest.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
@Test
public void testPathOperationComponent() throws URISyntaxException {
    String COMPONENT_NAME = "path_operation";
    Path outputDirectory = getOutputFile(COMPONENT_NAME);
    FileUtils.deleteQuietly(outputDirectory.toFile());

    //Given
    Path file = Paths.get(PathOperationComponentTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
    Swagger swagger = converter.getContext().getSchema();

    io.swagger.models.Path path = swagger.getPaths().get("/pets");
    List<SwaggerPathOperation> pathOperations = PathUtils.toPathOperationsList("/pets", path);

    Swagger2MarkupConverter.SwaggerContext context = converter.getContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    //When
    markupDocBuilder = new PathOperationComponent(context,
            new DefinitionDocumentResolverFromOperation(context),
            new SecurityDocumentResolver(context)).
            apply(markupDocBuilder, PathOperationComponent.parameters(pathOperations.get(0)));

    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    //Then
    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));
}
 
Example 17
Source File: PathOperationComponentTest.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
@Test
public void testInlineSchema() throws URISyntaxException {
    String COMPONENT_NAME = "path_operation_inline_schema";
    Path outputDirectory = getOutputFile(COMPONENT_NAME);
    FileUtils.deleteQuietly(outputDirectory.toFile());

    //Given
    Path file = Paths.get(PathOperationComponentTest.class.getResource("/yaml/swagger_inlineSchema.yaml").toURI());
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
    Swagger swagger = converter.getContext().getSchema();

    io.swagger.models.Path path = swagger.getPaths().get("/LaunchCommand");
    List<SwaggerPathOperation> pathOperations = PathUtils.toPathOperationsList("/LaunchCommand", path);

    Swagger2MarkupConverter.SwaggerContext context = converter.getContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    //When
    markupDocBuilder = new PathOperationComponent(context,
            new DefinitionDocumentResolverFromOperation(context),
            new SecurityDocumentResolver(context)).
            apply(markupDocBuilder, PathOperationComponent.parameters(pathOperations.get(0)));

    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    //Then
    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}
 
Example 18
Source File: PathOperationComponentTest.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithPathParamExample() throws URISyntaxException {
    String COMPONENT_NAME = "path_operation_with_path_param_example";
    Path outputDirectory = getOutputFile(COMPONENT_NAME);
    FileUtils.deleteQuietly(outputDirectory.toFile());

    Map<String, String> configMap = new HashMap<>();
    configMap.put("swagger2markup.generatedExamplesEnabled", "true");  // enable example

    //Given
    Path file = Paths.get(PathOperationComponentTest.class.getResource("/yaml/swagger_petstore.yaml").toURI());
    Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder(configMap).build();
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).withConfig(config) .build();
    Swagger swagger = converter.getContext().getSchema();

    io.swagger.models.Path path = swagger.getPaths().get("/pets/{petId}");
    List<SwaggerPathOperation> pathOperations = PathUtils.toPathOperationsList("/pets/{petId}", path);

    Swagger2MarkupConverter.SwaggerContext context = converter.getContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    //When
    markupDocBuilder = new PathOperationComponent(context,
            new DefinitionDocumentResolverFromOperation(context),
            new SecurityDocumentResolver(context)).
            apply(markupDocBuilder, PathOperationComponent.parameters(pathOperations.get(0)));

    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    //Then
    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));
}
 
Example 19
Source File: PathOperationComponentTest.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithBodyParamExample() throws URISyntaxException {
    String COMPONENT_NAME = "path_operation_with_body_param_example";
    Path outputDirectory = getOutputFile(COMPONENT_NAME);
    FileUtils.deleteQuietly(outputDirectory.toFile());

    Map<String, String> configMap = new HashMap<>();
    configMap.put("swagger2markup.generatedExamplesEnabled", "true");  // enable example

    //Given
    Path file = Paths.get(PathOperationComponentTest.class.getResource("/yaml/swagger_petstore_body_examples.yaml").toURI());
    Swagger2MarkupConfig config = new Swagger2MarkupConfigBuilder(configMap).build();
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).withConfig(config) .build();
    Swagger swagger = converter.getContext().getSchema();

    io.swagger.models.Path path = swagger.getPaths().get("/users");
    List<SwaggerPathOperation> pathOperations = PathUtils.toPathOperationsList("/users", path);

    Swagger2MarkupConverter.SwaggerContext context = converter.getContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    //When
    markupDocBuilder = new PathOperationComponent(context,
            new DefinitionDocumentResolverFromOperation(context),
            new SecurityDocumentResolver(context)).
            apply(markupDocBuilder, PathOperationComponent.parameters(pathOperations.get(0)));

    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    //Then
    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));
}
 
Example 20
Source File: ContactInfoComponentTest.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
@Test
public void testVersionInfoComponent() throws URISyntaxException {
    Contact contact = new Contact().name("TestName").email("[email protected]");

    Swagger2MarkupConverter.SwaggerContext context = createContext();
    MarkupDocBuilder markupDocBuilder = context.createMarkupDocBuilder();

    markupDocBuilder = new ContactInfoComponent(context).apply(markupDocBuilder, ContactInfoComponent.parameters(
            contact, OverviewDocument.SECTION_TITLE_LEVEL));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

    Path expectedFile = getExpectedFile(COMPONENT_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, outputDirectory, getReportName(COMPONENT_NAME));

}