Skip to content

Commit 564c7c7

Browse files
committed
scala fmt
1 parent 25cca63 commit 564c7c7

File tree

4 files changed

+23
-16
lines changed

4 files changed

+23
-16
lines changed

.scalafmt.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
# https://scalameta.org/scalafmt/docs/configuration.html
22
version = "3.5.9"
3+
runner.dialect = scala213source3
34
maxColumn = 140
45
project.git = true
56

src/main/scala-2/com/github/swagger/scala/converter/ErasureHelper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ private[converter] object ErasureHelper {
4040
} catch {
4141
case NonFatal(t) => {
4242
if (logger.isDebugEnabled) {
43-
//use this form because of Scala 2.11 & 2.12 compile issue
43+
// use this form because of Scala 2.11 & 2.12 compile issue
4444
logger.debug(s"Unable to get type info ${Option(cls.getName).getOrElse("null")}", t)
4545
} else {
4646
logger.info("Unable to get type info {}", Option(cls.getName).getOrElse("null"))

src/main/scala/com/github/swagger/scala/converter/SwaggerScalaModelConverter.scala

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,29 @@ object SwaggerScalaModelConverter {
2626
val objectMapper: ObjectMapper = Json.mapper().registerModule(DefaultScalaModule)
2727
private var requiredBasedOnAnnotation = true
2828

29-
/** [[io.swagger.v3.oas.annotations.media.Schema]] annotation has required = [[false]] by default
30-
* This means that all fields that aren't [[Option]] will, counter to what you would expect based on the type,
31-
* <b>not</b> be required by default.
32-
* If this behavior is undesired, set [[SwaggerScalaModelConverter.setRequiredBasedOnAnnotation]] to [[true]]
33-
* and the required property on the annotation will be ignored, unless the field is an [[Option]].
29+
/** If you use swagger annotations to override what is automatically derived, then be aware that
30+
* [[io.swagger.v3.oas.annotations.media.Schema]] annotation has required = [[false]], by default. You are advised to set the required
31+
* flag on this annotation to the correct value. If you would prefer to have the Schema annotation required flag ignored and to rely on
32+
* the this module inferring the value (as ot would if you don't annotate the classes or fields), then set
33+
* [[SwaggerScalaModelConverter.setRequiredBasedOnAnnotation]] to [[true]] and the required property on the annotation will be ignored,
34+
* unless the field is an [[Option]].
3435
*
35-
* @param value true by default
36+
* @param value
37+
* true by default
3638
*/
3739
def setRequiredBasedOnAnnotation(value: Boolean = true): Unit = {
3840
requiredBasedOnAnnotation = value
3941
}
4042

41-
/** [[io.swagger.v3.oas.annotations.media.Schema]] annotation has required = [[false]] by default
42-
* This means that all fields that aren't [[Option]] will, counter to what you would expect based on the type,
43-
* <b>not</b> be required by default.
44-
* If this behavior is undesired, set [[SwaggerScalaModelConverter.setRequiredBasedOnAnnotation]] to [[true]]
45-
* and the required property on the annotation will be ignored, unless the field is an [[Option]].
43+
/** If you use swagger annotations to override what is automatically derived, then be aware that
44+
* [[io.swagger.v3.oas.annotations.media.Schema]] annotation has required = [[false]], by default. You are advised to set the required
45+
* flag on this annotation to the correct value. If you would prefer to have the Schema annotation required flag ignored and to rely on
46+
* the this module inferring the value (as ot would if you don't annotate the classes or fields), then set
47+
* [[SwaggerScalaModelConverter.setRequiredBasedOnAnnotation]] to [[true]] and the required property on the annotation will be ignored,
48+
* unless the field is an [[Option]].
4649
*
47-
* @return value: true by default
50+
* @return
51+
* value: true by default
4852
*/
4953
def isRequiredBasedOnAnnotation: Boolean = requiredBasedOnAnnotation
5054
}

src/test/scala/com/github/swagger/scala/converter/ModelPropertyParserTest.scala

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,9 @@ class ModelPropertyParserTest extends AnyFlatSpec with BeforeAndAfterEach with M
169169
nullSafeSeq(model.value.getRequired) shouldBe empty
170170
}
171171

172-
it should "prioritize required as specified in annotation by default" in new PropertiesScope[ModelWOptionIntSchemaOverrideForRequired](true) {
172+
it should "prioritize required as specified in annotation by default" in new PropertiesScope[ModelWOptionIntSchemaOverrideForRequired](
173+
true
174+
) {
173175
val requiredIntWithDefault = model.value.getProperties.get("requiredIntWithDefault")
174176
requiredIntWithDefault shouldBe an[IntegerSchema]
175177
requiredIntWithDefault.asInstanceOf[IntegerSchema].getDefault shouldEqual 5
@@ -416,8 +418,8 @@ class ModelPropertyParserTest extends AnyFlatSpec with BeforeAndAfterEach with M
416418
stringsField shouldBe a[ArraySchema]
417419
val arraySchema = stringsField.asInstanceOf[ArraySchema]
418420
arraySchema.getUniqueItems() shouldBe (null)
419-
arraySchema.getItems shouldBe a[ObjectSchema] //probably type erasure - ideally this would eval as StringSchema
420-
//next line used to fail (https://github.com/swagger-akka-http/swagger-akka-http/issues/171)
421+
arraySchema.getItems shouldBe a[ObjectSchema] // probably type erasure - ideally this would eval as StringSchema
422+
// next line used to fail (https://github.com/swagger-akka-http/swagger-akka-http/issues/171)
421423
Json.mapper().writeValueAsString(model.value)
422424
}
423425

0 commit comments

Comments
 (0)