Skip to content

Commit 6c3ac25

Browse files
committed
ISSUE-2969 fix path to register resource handler to work SwaggerIndexPageTransformer considering /webjar path prefix - add test
1 parent a39ce4f commit 6c3ac25

File tree

2 files changed

+93
-0
lines changed

2 files changed

+93
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/*
2+
*
3+
* *
4+
* * *
5+
* * * * Copyright 2019-2020 the original author or authors.
6+
* * * *
7+
* * * * Licensed under the Apache License, Version 2.0 (the "License");
8+
* * * * you may not use this file except in compliance with the License.
9+
* * * * You may obtain a copy of the License at
10+
* * * *
11+
* * * * https://www.apache.org/licenses/LICENSE-2.0
12+
* * * *
13+
* * * * Unless required by applicable law or agreed to in writing, software
14+
* * * * distributed under the License is distributed on an "AS IS" BASIS,
15+
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* * * * See the License for the specific language governing permissions and
17+
* * * * limitations under the License.
18+
* * *
19+
* *
20+
*
21+
*
22+
*/
23+
24+
package test.org.springdoc.ui.app34;
25+
26+
import jakarta.validation.Valid;
27+
import jakarta.validation.constraints.Size;
28+
import org.springframework.web.bind.annotation.GetMapping;
29+
import org.springframework.web.bind.annotation.RequestParam;
30+
import org.springframework.web.bind.annotation.RestController;
31+
32+
@RestController
33+
public class HelloController {
34+
35+
@GetMapping(value = "/persons")
36+
public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) {
37+
38+
}
39+
40+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
/*
2+
*
3+
* *
4+
* * *
5+
* * * * Copyright 2019-2020 the original author or authors.
6+
* * * *
7+
* * * * Licensed under the Apache License, Version 2.0 (the "License");
8+
* * * * you may not use this file except in compliance with the License.
9+
* * * * You may obtain a copy of the License at
10+
* * * *
11+
* * * * https://www.apache.org/licenses/LICENSE-2.0
12+
* * * *
13+
* * * * Unless required by applicable law or agreed to in writing, software
14+
* * * * distributed under the License is distributed on an "AS IS" BASIS,
15+
* * * * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
* * * * See the License for the specific language governing permissions and
17+
* * * * limitations under the License.
18+
* * *
19+
* *
20+
*
21+
*
22+
*/
23+
24+
package test.org.springdoc.ui.app34;
25+
26+
import org.junit.jupiter.api.Test;
27+
import org.springframework.boot.autoconfigure.SpringBootApplication;
28+
import org.springframework.test.context.TestPropertySource;
29+
import org.springframework.test.web.reactive.server.EntityExchangeResult;
30+
import test.org.springdoc.ui.AbstractSpringDocTest;
31+
32+
import static org.junit.jupiter.api.Assertions.assertFalse;
33+
import static org.junit.jupiter.api.Assertions.assertTrue;
34+
35+
@TestPropertySource(properties = "springdoc.swagger-ui.disable-swagger-default-url=true")
36+
public class SpringDocApp34Test extends AbstractSpringDocTest {
37+
38+
@Test
39+
void transformed_index_with_oauth() throws Exception {
40+
EntityExchangeResult<byte[]> getResult = webTestClient.get().uri("/webjars/swagger-ui/swagger-initializer.js")
41+
.exchange()
42+
.expectStatus().isOk()
43+
.expectBody().returnResult();
44+
45+
var responseContent = new String(getResult.getResponseBody());
46+
assertFalse(responseContent.contains("https://petstore.swagger.io/v2/swagger.json"));
47+
assertTrue(responseContent.contains("/v3/api-docs"));
48+
}
49+
50+
@SpringBootApplication
51+
static class SpringDocTestApp {}
52+
53+
}

0 commit comments

Comments
 (0)