Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public Parameter buildParameterFromDoc(io.swagger.v3.oas.annotations.Parameter p
optionalContent.ifPresent(parameter::setContent);
}
else
setSchema(parameterDoc, components, jsonView, parameter);
setSchema(parameterDoc, components, jsonView, parameter, locale);

setExamples(parameterDoc, parameter);
setExtensions(parameterDoc, parameter, locale);
Expand All @@ -320,8 +320,9 @@ public Parameter buildParameterFromDoc(io.swagger.v3.oas.annotations.Parameter p
* @param components the components
* @param jsonView the json view
* @param parameter the parameter
* @param locale the locale
*/
private void setSchema(io.swagger.v3.oas.annotations.Parameter parameterDoc, Components components, JsonView jsonView, Parameter parameter) {
private void setSchema(io.swagger.v3.oas.annotations.Parameter parameterDoc, Components components, JsonView jsonView, Parameter parameter, Locale locale) {
if (StringUtils.isNotBlank(parameterDoc.ref()))
parameter.$ref(parameterDoc.ref());
else {
Expand All @@ -335,7 +336,11 @@ private void setSchema(io.swagger.v3.oas.annotations.Parameter parameterDoc, Com
PrimitiveType primitiveType = PrimitiveType.fromTypeAndFormat(schema.getType(), schema.getFormat());
if (primitiveType != null) {
Schema<?> primitiveSchema = primitiveType.createProperty();
primitiveSchema.setDefault(schema.getDefault());
if (schema.getDefault() instanceof String stringValue) {
primitiveSchema.setDefault(propertyResolverUtils.resolve(stringValue, locale));
} else {
primitiveSchema.setDefault(schema.getDefault());
}
schema.setDefault(primitiveSchema.getDefault());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

package test.org.springdoc.api.v30.app139;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -33,6 +36,10 @@
public class HelloController {

@GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test1")
@Parameter(name = "parameter", in = ParameterIn.QUERY,
schema = @Schema(type = "string", defaultValue = "${test.parameter-default-value}"))
@Parameter(name = "parameter-boolean", in = ParameterIn.QUERY,
schema = @Schema(type = "boolean", defaultValue = "${test.parameter-boolean-default-value}"))
public String echo1(@RequestParam(name = "${test.name}", defaultValue = "${test.default-value}") String text) {
return text;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,21 @@
*/
package test.org.springdoc.api.v30.app139;

import test.org.springdoc.api.v30.AbstractSpringDocV30Test;

import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.test.context.TestPropertySource;
import test.org.springdoc.api.v30.AbstractSpringDocV30Test;


/**
* Tests Spring meta-annotations as method parameters
*/
@TestPropertySource(properties = { "test.name=text", "test.value=text", "test.default-value=default-text" })
@TestPropertySource(properties = {
"test.name=text",
"test.value=text",
"test.default-value=default-text",
"test.parameter-default-value=parameter-text",
"test.parameter-boolean-default-value=true"
})
public class SpringDocApp139Test extends AbstractSpringDocV30Test {

@SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@

package test.org.springdoc.api.v31.app139;

import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.enums.ParameterIn;
import io.swagger.v3.oas.annotations.media.Schema;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
Expand All @@ -33,6 +36,10 @@
public class HelloController {

@GetMapping(produces = MediaType.TEXT_PLAIN_VALUE, path = "/test1")
@Parameter(name = "parameter", in = ParameterIn.QUERY,
schema = @Schema(type = "string", defaultValue = "${test.parameter-default-value}"))
@Parameter(name = "parameter-boolean", in = ParameterIn.QUERY,
schema = @Schema(type = "boolean", defaultValue = "${test.parameter-boolean-default-value}"))
public String echo1(@RequestParam(name = "${test.name}", defaultValue = "${test.default-value}") String text) {
return text;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@
/**
* Tests Spring meta-annotations as method parameters
*/
@TestPropertySource(properties = { "test.name=text", "test.value=text", "test.default-value=default-text" })
@TestPropertySource(properties = {
"test.name=text",
"test.value=text",
"test.default-value=default-text",
"test.parameter-default-value=parameter-text",
"test.parameter-boolean-default-value=true"
})
public class SpringDocApp139Test extends AbstractSpringDocTest {

@SpringBootApplication
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@
"type": "string",
"default": "default-text"
}
},
{
"name" : "parameter",
"in" : "query",
"schema" : {
"type" : "string",
"default": "parameter-text"
}
},
{
"name" : "parameter-boolean",
"in" : "query",
"schema" : {
"type" : "boolean",
"default": true
}
}
],
"responses": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,22 @@
"type": "string",
"default": "default-text"
}
},
{
"name" : "parameter",
"in" : "query",
"schema" : {
"type" : "string",
"default": "parameter-text"
}
},
{
"name" : "parameter-boolean",
"in" : "query",
"schema" : {
"type" : "boolean",
"default": true
}
}
],
"responses": {
Expand Down