Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

Restii #177

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Restii #177

wants to merge 11 commits into from

Conversation

skdong
Copy link
Contributor

@skdong skdong commented Apr 28, 2020

[document] Apis - auto genrate Rest API docs (#150)(#176)

Add api-gateway, mac-manager,subnet-manager,privateip-manger Spring REST Docs generated code

@xieus xieus added build related enhancement New feature or request labels Apr 28, 2020
@xieus xieus added this to the Version 0.4.2020.04.30 milestone Apr 28, 2020
@xieus xieus linked an issue Apr 28, 2020 that may be closed by this pull request
Copy link
Contributor

@xieus xieus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing to the community. This is a good first work.

@@ -108,7 +111,8 @@ public String createMacRange(MacRange macRange) {
public void test_index() throws Exception {
this.mockMvc.perform(get("/start.html"))
.andDo(print())
.andExpect(status().isOk());
.andExpect(status().isOk())
.andDo(document("start"));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we use "mac_range_post"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • This corresponds to the directory name of the generated document. I think the name and the request are the same for easy search. I can change it if necessary, but it cannot conflict with other requests, otherwise it will overwrite the file

import static com.github.tomakehurst.wiremock.client.WireMock.*;
import static org.assertj.core.api.Assertions.*;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,
properties = {"httpbin=http://localhost:${wiremock.server.port}"})
@AutoConfigureWireMock(port = 0)
@AutoConfigureRestDocs(outputDir = "target/generated-snippets")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If most of the 126 files on the other PR could be found in the target/generated-snippets directory, that would be great. This means that we could safely remove those files in the /docs/apis/ directory as we could always find the latest by running "mvn test". right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quick question: are we able to find the html files like alcor/docs/apis/mac-manager/swagger/html/index.html in the target/generated-snippets directory?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • Yes, we can generate those files under the target / generated-snippets directory by executing mvn test

  • The code for the swagger part has not been submitted. Currently, Swagger documentation can be viewed by visiting the /swagger-ui.html path after the microservice is started. Before, I used a separate html generated by a third-party tool. I tried to generate html automatically when I tried mvn test.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! How can we access the /swagger-ui.html if the microservice is not started?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found some ways to generate swagger html files during mvn test, I am now verifying

@@ -87,6 +87,17 @@
<version>0.1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We just merged new UTs to VPC and Route Controllers. Could you please add the docs accordingly. Thank you.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok let me add it

Now there is a problem, most microservices mvn test need to connect to the database, I currently deploy the database can be executed, but it is best to be able to leave the database

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to have a flag which could switch off DB access when generating the docs?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The document is generated after the unit test is completed. As long as the unit test does not depend on the database during execution, the document can be generated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see. Please work with @chenpiaoping to see if we can support DB-related UTs by Ignite mock.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
build related enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Documentation] Auto-generated Spring REST doc
3 participants