Java Code Examples for io.github.swagger2markup.Swagger2MarkupConverter#getContext()

The following examples show how to use io.github.swagger2markup.Swagger2MarkupConverter#getContext() . 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: 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 2
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 3
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 4
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 5
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 6
Source File: SwaggerUtils.java    From swagger-showdoc with Apache License 2.0 6 votes vote down vote up
private static String generateMd(Swagger swagger, String k, Path swaggerPath,String swaggerUiUrl){
    StringBuilder builder = new StringBuilder();

    Map<String, Path> paths = new HashMap<>();
    paths.put(k,swaggerPath);
    swagger.setPaths(paths);

    Swagger2MarkupConverter swagger2MarkupConverter = XforcceSwagger2MarkupConverter.from(swagger).withConfig(config).build();
    Swagger2MarkupConverter.Context context = swagger2MarkupConverter.getContext();
    XforcceSwagger2MarkupConverter xforcceSwagger2MarkupConverter = new XforcceSwagger2MarkupConverter(context);

    builder.append(xforcceSwagger2MarkupConverter.toString()).append("\n").append("#### 在线调试").append("\n").append("[模拟调用](").append(swaggerUiUrl).append(getExternalDocs(swaggerPath)).append(")");

    String s = SwaggerUtils.doPathWithParameter(swagger, swaggerPath);
    builder.append(s);
    return builder.toString();
}
 
Example 7
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 8
Source File: SecuritySchemeDefinitionComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testSecuritySchemeDefinitionComponentWithOAuth() 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("petstore_auth");

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

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

    Path expectedFile = getExpectedFile(O_AUTH_NAME);
    DiffUtils.assertThatFileIsEqual(expectedFile, oauthOutputDirectory, getReportName(O_AUTH_NAME));

}
 
Example 9
Source File: DefinitionComponentTest.java    From swagger2markup with Apache License 2.0 6 votes vote down vote up
@Test
public void testDefinitionComponent() throws URISyntaxException {
    //Given
    Path file = Paths.get(DefinitionComponentTest.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();

    //When
    markupDocBuilder = new DefinitionComponent(context, new DefinitionDocumentResolverFromDefinition(context))
            .apply(markupDocBuilder, DefinitionComponent.parameters("Pet", petModel, 2));
    markupDocBuilder.writeToFileWithoutExtension(outputDirectory, StandardCharsets.UTF_8);

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

}
 
Example 10
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 11
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 12
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 13
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 14
Source File: PathOperationComponentTest.java    From swagger2markup with Apache License 2.0 5 votes vote down vote up
@Test
public void testWithQueryParamExample() throws URISyntaxException {
    String COMPONENT_NAME = "path_operation_with_query_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/findByTags");
    List<SwaggerPathOperation> pathOperations = PathUtils.toPathOperationsList("/pets/findByTags", 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 15
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 16
Source File: SwaggerUtils.java    From swagger-showdoc with Apache License 2.0 5 votes vote down vote up
private static String definitionsDocumentGenerateMd(Swagger swagger,String modelKey,Model model){
    Map<String, Model> definitions = new HashMap<>();
    definitions.put(modelKey,model);
    swagger.setDefinitions(definitions);


    Swagger2MarkupConverter swagger2MarkupConverter = XforcceSwagger2MarkupConverter.from(swagger).withConfig(config).build();
    Swagger2MarkupConverter.Context context = swagger2MarkupConverter.getContext();
    XforcceSwagger2MarkupConverter xforcceSwagger2MarkupConverter = new XforcceSwagger2MarkupConverter(context);
    return xforcceSwagger2MarkupConverter.definitionsDocumenttoString();
}
 
Example 17
Source File: ParameterAdapterTest.java    From swagger2markup with Apache License 2.0 4 votes vote down vote up
@Test
public void testParameterWrapper() throws URISyntaxException {
    //Given
    Path file = Paths.get(ParameterAdapterTest.class.getResource("/yaml/swagger_inlineSchema.yaml").toURI());
    Swagger2MarkupConverter converter = Swagger2MarkupConverter.from(file).build();
    Swagger2MarkupConverter.SwaggerContext context = converter.getContext();
    Swagger swagger = context.getSchema();

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

    SwaggerPathOperation operation = pathOperations.get(0);
    List<Parameter> parameters = operation.getOperation().getParameters();
    DefinitionDocumentResolverFromOperation resolverFromOperation = new DefinitionDocumentResolverFromOperation(context);

    //Test Query Parameter
    Parameter queryParamter = parameters.get(0);
    ParameterAdapter queryParameterAdapter = new ParameterAdapter(
            context,
            operation,
            queryParamter,
            resolverFromOperation);
    Type type = queryParameterAdapter.getType();

    assertThat(queryParameterAdapter.getIn()).isEqualTo("Query");
    assertThat(type).isInstanceOf(BasicType.class);
    assertThat(type.getName()).isEqualTo("Version");
    assertThat(type.getUniqueName()).isEqualTo("Version");
    assertThat(((BasicType) type).getType()).isEqualTo("string");

    //Test Body Parameter
    Parameter bodyParameter = parameters.get(2);
    ParameterAdapter bodyParameterAdapter = new ParameterAdapter(
            context,
            operation,
            bodyParameter,
            resolverFromOperation);
    type = bodyParameterAdapter.getType();

    assertThat(bodyParameterAdapter.getIn()).isEqualTo("Body");
    assertThat(type).isInstanceOf(RefType.class);
    Type refType = ((RefType) type).getRefType();
    assertThat(refType).isInstanceOf(ObjectType.class);
    ObjectType objectType = (ObjectType) refType;
    assertThat(objectType.getProperties()).hasSize(3);

    //Inline Schema
    assertThat(bodyParameterAdapter.getInlineDefinitions()).hasSize(1);
}
 
Example 18
Source File: SwaggerUtils.java    From swagger-showdoc with Apache License 2.0 4 votes vote down vote up
private static String securityDocumentGenerateMd(Swagger swagger){
    Swagger2MarkupConverter swagger2MarkupConverter = XforcceSwagger2MarkupConverter.from(swagger).withConfig(config).build();
    Swagger2MarkupConverter.Context context = swagger2MarkupConverter.getContext();
    XforcceSwagger2MarkupConverter xforcceSwagger2MarkupConverter = new XforcceSwagger2MarkupConverter(context);
    return xforcceSwagger2MarkupConverter.securityDocumenttoString();
}
 
Example 19
Source File: SwaggerUtils.java    From swagger-showdoc with Apache License 2.0 4 votes vote down vote up
private static String overviewDocumentGenerateMd(Swagger swagger){
        Swagger2MarkupConverter swagger2MarkupConverter = XforcceSwagger2MarkupConverter.from(swagger).withConfig(config).build();
        Swagger2MarkupConverter.Context context = swagger2MarkupConverter.getContext();
        XforcceSwagger2MarkupConverter xforcceSwagger2MarkupConverter = new XforcceSwagger2MarkupConverter(context);
        return xforcceSwagger2MarkupConverter.overviewDocumenttoString();
}