@@ -30,9 +30,9 @@ object SwaggerScalaModelConverter {
3030 private var requiredBasedOnDefaultValue = true
3131
3232 /** If you use swagger annotations to override what is automatically derived, then be aware that
33- * [[io.swagger.v3.oas.annotations.media.Schema ]] annotation has required = false, by default. You are advised to set the required
34- * flag on this annotation to the correct value. If you would prefer to have the Schema annotation required flag ignored and to rely on
35- * the this module inferring the value (as it would if you don't annotate the classes or fields), then set
33+ * [[io.swagger.v3.oas.annotations.media.Schema ]] annotation has required = false, by default. You are advised to set the required flag
34+ * on this annotation to the correct value. If you would prefer to have the Schema annotation required flag ignored and to rely on the
35+ * this module inferring the value (as it would if you don't annotate the classes or fields), then set
3636 * [[SwaggerScalaModelConverter.setRequiredBasedOnAnnotation ]] to true and the required property on the annotation will be ignored,
3737 * unless the field is an [[Option ]].
3838 *
@@ -44,11 +44,11 @@ object SwaggerScalaModelConverter {
4444 requiredBasedOnAnnotation = value
4545 }
4646
47- /** If you use swagger annotations to override what is automatically derived, then this flag will not be used.
48- * If you rely on this module inferring the required flag (as it would if you don't annotate the classes or fields),
49- * then this flag will control how the required flag is derived when a default value exists.
50- * If [[ SwaggerScalaModelConverter.setRequiredBasedOnDefaultValue ]] is true and a property has a default value, then it will not be required.
51- * However, if this flag is false, then a property will be required only if it's not an [[Option ]].
47+ /** If you use swagger annotations to override what is automatically derived, then this flag will not be used. If you rely on this module
48+ * inferring the required flag (as it would if you don't annotate the classes or fields), then this flag will control how the required
49+ * flag is derived when a default value exists. If [[ SwaggerScalaModelConverter.setRequiredBasedOnDefaultValue ]] is true and a property
50+ * has a default value, then it will not be required. However, if this flag is false, then a property will be required only if it's not
51+ * an [[Option ]].
5252 *
5353 * @param value
5454 * true by default
@@ -59,28 +59,28 @@ object SwaggerScalaModelConverter {
5959 }
6060
6161 /** If you use swagger annotations to override what is automatically derived, then be aware that
62- * [[io.swagger.v3.oas.annotations.media.Schema ]] annotation has required = false, by default. You are advised to set the required
63- * flag on this annotation to the correct value. If you would prefer to have the Schema annotation required flag ignored and to rely on
64- * the this module inferring the value (as it would if you don't annotate the classes or fields), then set
62+ * [[io.swagger.v3.oas.annotations.media.Schema ]] annotation has required = false, by default. You are advised to set the required flag
63+ * on this annotation to the correct value. If you would prefer to have the Schema annotation required flag ignored and to rely on the
64+ * this module inferring the value (as it would if you don't annotate the classes or fields), then set
6565 * [[SwaggerScalaModelConverter.setRequiredBasedOnAnnotation ]] to true and the required property on the annotation will be ignored,
6666 * unless the field is an [[Option ]].
6767 *
68- * @return value
69- * value: true by default
68+ * @return
69+ * value value : true by default
7070 * @since v2.7.4
7171 */
7272 def isRequiredBasedOnAnnotation : Boolean = requiredBasedOnAnnotation
7373
74- /** If you use swagger annotations to override what is automatically derived, then this flag will not be used.
75- * If you rely on this module inferring the required flag (as it would if you don't annotate the classes or fields),
76- * then this flag will control how the required flag is derived when a default value exists.
77- * If [[ SwaggerScalaModelConverter.setRequiredBasedOnDefaultValue ]] is true and a property has a default value, then it will not be required.
78- * However, if this flag is false, then a property will be required only if it's not an [[Option ]].
74+ /** If you use swagger annotations to override what is automatically derived, then this flag will not be used. If you rely on this module
75+ * inferring the required flag (as it would if you don't annotate the classes or fields), then this flag will control how the required
76+ * flag is derived when a default value exists. If [[ SwaggerScalaModelConverter.setRequiredBasedOnDefaultValue ]] is true and a property
77+ * has a default value, then it will not be required. However, if this flag is false, then a property will be required only if it's not
78+ * an [[Option ]].
7979 *
8080 * @return
8181 * value: true by default
8282 * @since v2.7.6
83- */
83+ */
8484 def isRequiredBasedOnDefaultValue : Boolean = requiredBasedOnDefaultValue
8585}
8686
@@ -118,8 +118,12 @@ class SwaggerScalaModelConverter extends ModelResolver(SwaggerScalaModelConverte
118118 }
119119 }
120120
121- private def resolveWithoutSubtypes (javaType : JavaType , `type` : AnnotatedType , context : ModelConverterContext ,
122- chain : util.Iterator [ModelConverter ]): Schema [_] = {
121+ private def resolveWithoutSubtypes (
122+ javaType : JavaType ,
123+ `type` : AnnotatedType ,
124+ context : ModelConverterContext ,
125+ chain : util.Iterator [ModelConverter ]
126+ ): Schema [_] = {
123127 val cls = javaType.getRawClass
124128 matchScalaPrimitives(`type`, cls).getOrElse {
125129 // Unbox scala options
@@ -128,7 +132,7 @@ class SwaggerScalaModelConverter extends ModelResolver(SwaggerScalaModelConverte
128132 val baseType =
129133 if (
130134 SwaggerScalaModelConverter .isRequiredBasedOnAnnotation
131- && annotatedOverrides.headOption.getOrElse(false )
135+ && annotatedOverrides.headOption.getOrElse(false )
132136 ) new AnnotatedType ()
133137 else new AnnotatedTypeForOption ()
134138 resolve(nextType(baseType, `type`, javaType), context, chain)
@@ -198,7 +202,7 @@ class SwaggerScalaModelConverter extends ModelResolver(SwaggerScalaModelConverte
198202 case _ => {
199203 defaultValue match {
200204 case Some (wrappedValue) => property.setDefault(wrappedValue)
201- case None => // no default
205+ case None => // no default
202206 case seq : Seq [_] => property.setDefault(seq.asJava)
203207 case set : Set [_] => property.setDefault(set.asJava)
204208 case dv => property.setDefault(dv)
@@ -317,7 +321,6 @@ class SwaggerScalaModelConverter extends ModelResolver(SwaggerScalaModelConverte
317321 }
318322 }
319323
320-
321324 private def getRequiredSettings (annotatedType : AnnotatedType ): Seq [Boolean ] = annotatedType match {
322325 case _ : AnnotatedTypeForOption => Seq .empty
323326 case _ => getRequiredSettings(nullSafeSeq(annotatedType.getCtxAnnotations))
0 commit comments