File tree 3 files changed +60
-0
lines changed
integrationTest/java/uk/gov/hmcts/reform/bulkscanprocessor/config
3 files changed +60
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Publish OpenAPI specs
2
+ on :
3
+ push :
4
+ branches :
5
+ - " master"
6
+
7
+ jobs :
8
+ publish-openapi :
9
+ uses : hmcts/workflow-publish-openapi-spec/.github/workflows/publish-openapi.yml@v1
10
+ secrets :
11
+ SWAGGER_PUBLISHER_API_TOKEN : ${{ secrets.SWAGGER_PUBLISHER_API_TOKEN }}
12
+ with :
13
+ test_to_run : ' uk.gov.hmcts.reform.bulkscanprocessor.config.SwaggerPublisher'
14
+ java_version : 17
Original file line number Diff line number Diff line change
1
+ package uk .gov .hmcts .reform .bulkscanprocessor .config ;
2
+
3
+ import org .junit .jupiter .api .DisplayName ;
4
+ import org .junit .jupiter .api .Test ;
5
+ import org .springframework .beans .factory .annotation .Autowired ;
6
+ import org .springframework .boot .test .autoconfigure .web .servlet .AutoConfigureMockMvc ;
7
+ import org .springframework .test .web .servlet .MockMvc ;
8
+
9
+ import java .io .OutputStream ;
10
+ import java .nio .file .Files ;
11
+ import java .nio .file .Paths ;
12
+
13
+ import static org .springframework .test .web .servlet .request .MockMvcRequestBuilders .get ;
14
+ import static org .springframework .test .web .servlet .result .MockMvcResultMatchers .status ;
15
+
16
+ /**
17
+ * Built-in feature which saves service's swagger specs in temporary directory.
18
+ * HMCTS GitHub workflow automatically runs on master and publishes to cnp-api-docs.
19
+ */
20
+ @ AutoConfigureMockMvc
21
+ @ IntegrationTest
22
+ class SwaggerPublisher {
23
+
24
+ @ Autowired
25
+ private MockMvc mvc ;
26
+
27
+ @ DisplayName ("Generate swagger documentation" )
28
+ @ Test
29
+ @ SuppressWarnings ("PMD.JUnitTestsShouldIncludeAssert" )
30
+ void generateDocs () throws Exception {
31
+ byte [] specs = mvc .perform (get ("/v3/api-docs" ))
32
+ .andExpect (status ().isOk ())
33
+ .andReturn ()
34
+ .getResponse ()
35
+ .getContentAsByteArray ();
36
+
37
+ try (OutputStream outputStream = Files .newOutputStream (Paths .get ("/tmp/openapi-specs.json" ))) {
38
+ outputStream .write (specs );
39
+ }
40
+
41
+ }
42
+ }
Original file line number Diff line number Diff line change 269
269
launchdarkly :
270
270
sdk-key : ${LAUNCH_DARKLY_SDK_KEY:XXXXX}
271
271
offline-mode : ${LAUNCH_DARKLY_OFFLINE_MODE:false}
272
+
273
+ springdoc :
274
+ packagesToScan : uk.gov.hmcts.reform.bulkscanprocessor.controllers
275
+ pathsToMatch : /**
You can’t perform that action at this time.
0 commit comments