Skip to content

Commit 63f15b5

Browse files
committed
Merge branch 'quom-add_try_it_out_enabled'
2 parents 1346f01 + eeddb43 commit 63f15b5

File tree

4 files changed

+105
-0
lines changed

4 files changed

+105
-0
lines changed

springdoc-openapi-common/src/main/java/org/springdoc/core/AbstractSwaggerUiConfigProperties.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,11 +159,32 @@ public abstract class AbstractSwaggerUiConfigProperties {
159159
*/
160160
protected SyntaxHighlight syntaxHighlight;
161161

162+
/**
163+
* Try it out enabled
164+
*/
165+
protected Boolean tryItOutEnabled;
166+
162167
/**
163168
* The Persist authorization.
164169
*/
165170
protected Boolean persistAuthorization;
166171

172+
/**
173+
* Gets try it out enabled
174+
* @return try it out enabled
175+
*/
176+
public Boolean getTryItOutEnabled() {
177+
return tryItOutEnabled;
178+
}
179+
180+
/**
181+
* Sets try it out enabled
182+
* @param tryItOutEnabled try it out enabled
183+
*/
184+
public void setTryItOutEnabled(Boolean tryItOutEnabled) {
185+
this.tryItOutEnabled = tryItOutEnabled;
186+
}
187+
167188
/**
168189
* Gets persist authorization.
169190
*

springdoc-openapi-common/src/main/java/org/springdoc/core/SwaggerUiConfigParameters.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ public SwaggerUiConfigParameters(SwaggerUiConfigProperties swaggerUiConfig) {
117117
this.urlsPrimaryName = swaggerUiConfig.getUrlsPrimaryName();
118118
this.groupsOrder = swaggerUiConfig.getGroupsOrder();
119119
this.syntaxHighlight = swaggerUiConfig.getSyntaxHighlight();
120+
this.tryItOutEnabled = swaggerUiConfig.getTryItOutEnabled();
120121
this.persistAuthorization = swaggerUiConfig.getPersistAuthorization();
121122
}
122123

@@ -206,6 +207,7 @@ public Map<String, Object> getConfigParameters() {
206207
SpringDocPropertiesUtils.put("url", url, params);
207208
put(URLS_PROPERTY, urls, params);
208209
SpringDocPropertiesUtils.put("urls.primaryName", urlsPrimaryName, params);
210+
SpringDocPropertiesUtils.put("tryItOutEnabled", tryItOutEnabled, params);
209211
SpringDocPropertiesUtils.put("persistAuthorization", persistAuthorization, params);
210212
return params;
211213
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.ui.app18;
20+
21+
import org.springframework.web.bind.annotation.GetMapping;
22+
import org.springframework.web.bind.annotation.RequestParam;
23+
import org.springframework.web.bind.annotation.RestController;
24+
25+
import javax.validation.Valid;
26+
import javax.validation.constraints.Size;
27+
28+
@RestController
29+
public class HelloController {
30+
31+
@GetMapping(value = "/persons")
32+
public void persons(@Valid @RequestParam @Size(min = 4, max = 6) String name) {
33+
34+
}
35+
36+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
*
3+
* * Copyright 2019-2020 the original author or authors.
4+
* *
5+
* * Licensed under the Apache License, Version 2.0 (the "License");
6+
* * you may not use this file except in compliance with the License.
7+
* * You may obtain a copy of the License at
8+
* *
9+
* * https://www.apache.org/licenses/LICENSE-2.0
10+
* *
11+
* * Unless required by applicable law or agreed to in writing, software
12+
* * distributed under the License is distributed on an "AS IS" BASIS,
13+
* * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* * See the License for the specific language governing permissions and
15+
* * limitations under the License.
16+
*
17+
*/
18+
19+
package test.org.springdoc.ui.app18;
20+
21+
import org.junit.jupiter.api.Test;
22+
import test.org.springdoc.ui.AbstractSpringDocTest;
23+
24+
import org.springframework.boot.autoconfigure.SpringBootApplication;
25+
import org.springframework.test.context.TestPropertySource;
26+
27+
import static org.hamcrest.CoreMatchers.equalTo;
28+
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
29+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;
30+
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;
31+
32+
@TestPropertySource(properties = "springdoc.swagger-ui.try-it-out-enabled=true" )
33+
public class SpringDocApp18Test extends AbstractSpringDocTest {
34+
35+
@Test
36+
public void testTryItOutEnabled() throws Exception {
37+
mockMvc.perform(get("/v3/api-docs/swagger-config"))
38+
.andExpect(status().isOk())
39+
.andExpect(jsonPath("tryItOutEnabled", equalTo("true")));
40+
}
41+
42+
@SpringBootApplication
43+
static class SpringDocTestApp {
44+
}
45+
46+
}

0 commit comments

Comments
 (0)