Skip to content

Commit 5a4ba60

Browse files
committed
move the version parsing to a separate file
1 parent c8dad84 commit 5a4ba60

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed
Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package com.yelp.codegen.plugin
22

3-
import io.swagger.parser.SwaggerParser
4-
import java.io.File
53
import javax.inject.Inject
64
import org.gradle.api.Action
75
import org.gradle.api.Project
@@ -23,22 +21,4 @@ abstract class GenerateTaskConfiguration @Inject constructor(project: Project) {
2321
val features: FeatureConfiguration = FeatureConfiguration(objects)
2422

2523
fun features(action: Action<FeatureConfiguration>) = action.execute(features)
26-
27-
companion object {
28-
private fun readVersionFromSpecfile(specFile: File): String {
29-
val swaggerSpec = SwaggerParser().readWithInfo(specFile.absolutePath, listOf(), false).swagger
30-
31-
return when (val version = swaggerSpec.info.version) {
32-
is String -> {
33-
println("Successfully read version from Swagger Spec file: $version")
34-
version
35-
}
36-
else -> {
37-
val defaultVersion = "0.0.0"
38-
println("Issue in reading version from Swagger Spec file. Falling back to $defaultVersion")
39-
defaultVersion
40-
}
41-
}
42-
}
43-
}
4424
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.yelp.codegen.plugin
2+
3+
import io.swagger.parser.SwaggerParser
4+
import java.io.File
5+
6+
fun readVersionFromSpecfile(specFile: File): String {
7+
val swaggerSpec = SwaggerParser().readWithInfo(specFile.absolutePath, listOf(), false).swagger
8+
9+
return when (val version = swaggerSpec.info.version) {
10+
is String -> {
11+
println("Successfully read version from Swagger Spec file: $version")
12+
version
13+
}
14+
else -> {
15+
val defaultVersion = "0.0.0"
16+
println("Issue in reading version from Swagger Spec file. Falling back to $defaultVersion")
17+
defaultVersion
18+
}
19+
}
20+
}

0 commit comments

Comments
 (0)