-
-
Notifications
You must be signed in to change notification settings - Fork 523
'required' attribute does not work in @Schema #1468
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
it's useless to create duplicates #1285 |
#1285 (comment) *Also, my other issue was deleted. Issues are meant to be deleted when the posts are clearly vandalizing the space. Please be respectful of the community as a moderator. |
You are creating too many duplicates and it's just not productive. That's why your other duplicate issue were deleted. Let me know if the workaround helps you:
import kotlin.Deprecated;
import kotlin.coroutines.Continuation;
import org.springdoc.core.SpringDocUtils;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
import org.springframework.boot.autoconfigure.condition.ConditionalOnWebApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Lazy;
/**
* The type Spring doc kotlin configuration.
* @author bnasslahsen
*/
@Lazy(false)
@Configuration(proxyBeanMethods = false)
@ConditionalOnClass(Continuation.class)
@ConditionalOnWebApplication
public class SpringDocKotlinConfiguration {
static {
SpringDocUtils.getConfig().addRequestWrapperToIgnore(Continuation.class)
.addDeprecatedType(Deprecated.class);
}
/**
* Kotlin coroutines return type parser kotlin coroutines return type parser.
*
* @return the kotlin coroutines return type parser
*/
@Bean
@Lazy(false)
@ConditionalOnMissingBean
KotlinCoroutinesReturnTypeParser kotlinCoroutinesReturnTypeParser() {
return new KotlinCoroutinesReturnTypeParser();
}
} And import java.lang.reflect.Method;
import java.lang.reflect.Parameter;
import java.lang.reflect.ParameterizedType;
import java.lang.reflect.Type;
import java.lang.reflect.WildcardType;
import java.util.Arrays;
import java.util.Optional;
import kotlin.coroutines.Continuation;
import org.springdoc.core.ReturnTypeParser;
import org.springframework.core.MethodParameter;
/**
* The type Kotlin coroutines return type parser.
* @author bnasslahsen
*/
public class KotlinCoroutinesReturnTypeParser implements ReturnTypeParser {
@Override
public Type getReturnType(MethodParameter methodParameter) {
Method method = methodParameter.getMethod();
Type returnType = Object.class;
assert method != null;
Optional<Parameter> continuationParameter = Arrays.stream(method.getParameters())
.filter(parameter -> parameter.getType().getCanonicalName().equals(Continuation.class.getCanonicalName()))
.findFirst();
if (continuationParameter.isPresent()) {
Type continuationType = continuationParameter.get().getParameterizedType();
if (continuationType instanceof ParameterizedType) {
Type actualTypeArguments = ((ParameterizedType) continuationType).getActualTypeArguments()[0];
if (actualTypeArguments instanceof WildcardType)
returnType = ((WildcardType) actualTypeArguments).getLowerBounds()[0];
}
}
return returnType;
}
}
|
Hi there. I really don't know why have you closed this issue and why you locked conversation in #1285. There is a difference between nullability and required in the schema. When I set
The format property is still required, even when it has a default value and the |
Describe the bug
the
required
attribute for the@Schema
is not reflected on the openapi response.any help is appreciated
To Reproduce
Steps to reproduce the behavior:
What version of spring-boot you are using?
2.3.7.RELEASE
What modules and versions of springdoc-openapi are you using?
dependency("org.springdoc:springdoc-openapi-ui:1.5.13")
dependency("org.springdoc:springdoc-openapi-kotlin:1.5.13")
What is the actual and the expected result using OpenAPI Description (yml or json)?
actual:
expected:
Expected behavior
required
attribute should be the final value for the fieldThe text was updated successfully, but these errors were encountered: