0

我不知道您如何使用 JavaDocs 和 Spring Auto Rest Docs。我可以使用 STS、UI 选项在本地生成我的 java-docs。但是,我不确定如何使用 Spring Auto Rest Docs 生成 java-docs。我尝试在 POM 中编写一些插件。但是 auto-description.adoc 和许多其他文档仍然是空的。

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>2.10.3</version>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-javadoc-plugin</artifactId>
            <version>3.0.0</version>
            <extensions>true</extensions>
            <executions>
                <execution>
                    <id>attach-javadocs</id>
                    <goals>
                        <goal>jar</goal>
                    </goals>
                    <configuration>
                        <!-- switch on dependency-driven aggregation -->
                        <includeDependencySources>true</includeDependencySources>
                    </configuration>
                </execution>
                <execution>
                    <id>generate-javadoc-json</id>
                    <phase>compile</phase>
                    <goals>
                        <goal>javadoc-no-fork</goal>
                    </goals>
                    <configuration>
                        <doclet>capital.scalable.restdocs.jsondoclet.ExtractDocumentationAsJsonDoclet</doclet>
                        <docletArtifact>
                            <groupId>capital.scalable</groupId>
                            <artifactId>spring-auto-restdocs-json-doclet</artifactId>
                        </docletArtifact>
                        <additionalparam>
                                -d ${project.build.directory}/site/doccheck
                        </additionalparam>
                        <reportOutputDirectory>${project.build.directory}</reportOutputDirectory>
                        <useStandardDocletOptions>false</useStandardDocletOptions>
                        <show>package</show>
                    </configuration>
                </execution>
            </executions>
        </plugin>

基本上我不知道如何让 Spring Auto Rest Docs 使用 Java Docs 来查找路径参数。我可以在终端上使用 mvn javadoc:javadoc 命令来创建在 target/site/apidocs/ 文件夹中创建的 Javadocs。但是我的 auto-path-parameters.adoc 中仍然没有参数

这是控制器,我使用的是 GraphQL,所以它不同:

/**
 * Query Controller Class
 * @author shantanu
 *
 */
@RestController
@RequestMapping(value="/graphql")
public class QueryController {

    @Value("classpath:/graphql/actionItm.graphqls")
    private Resource schemaResource;



    private GraphQL graphQL;


    @Autowired
    @Qualifier("graphQLDate")
    private GraphQLScalarType Date;



    @Autowired
    private AllActionItemsDataFetcher allActionItemsDataFetcher;

    @Autowired
    private ActionItemDataFetcher actionItemDataFetcher;


    @Autowired
    private PageActionItemDataFetcher pageActionItemDataFetcher;

    @PostConstruct
    public void loadSchema() throws IOException {
        File schemaFile = schemaResource.getFile();
        TypeDefinitionRegistry typeRegistry = new SchemaParser().parse(schemaFile);
        RuntimeWiring wiring = buildRuntimeWiring();
        GraphQLSchema schema = new SchemaGenerator().makeExecutableSchema(typeRegistry, wiring);
        graphQL = GraphQL.newGraphQL(schema).build();

    }

    private RuntimeWiring buildRuntimeWiring() {


        return RuntimeWiring.newRuntimeWiring()
                .type("Query", typeWiring -> typeWiring
                        .dataFetcher("findAllActionItems", allActionItemsDataFetcher)
                        .dataFetcher("findActionItem", actionItemDataFetcher)
                        .dataFetcher("pageActionItems", pageActionItemDataFetcher))
                        .scalar(Date)

                .build();
    }

    /**
     * This
     * @param query Description
     * @return ResponseEntity responseEntity
     */
    @PostMapping
    public ResponseEntity query(@RequestBody String query) {
        ExecutionResult result = graphQL.execute(query);
        return ResponseEntity.ok(result.getData());

    }

}

使用路径参数,我没有得到错误的地方。并且只有 .adoc 文件是使用 Spring Auto Rest Docs 生成的,没有 JSON 文件。

4

0 回答 0