forked from loafle/openapi-generator-original
removed unused code
This commit is contained in:
parent
31e65969b3
commit
d91da857a0
@ -43,7 +43,7 @@ object Codegen {
|
||||
|
||||
class Codegen(config: CodegenConfig) {
|
||||
implicit val formats = SwaggerSerializers.formats("1.2")
|
||||
|
||||
/*
|
||||
@deprecated
|
||||
def generateSource(bundle: Map[String, AnyRef], templateFile: String): String = {
|
||||
val allImports = new HashSet[String]
|
||||
@ -170,7 +170,7 @@ class Codegen(config: CodegenConfig) {
|
||||
output
|
||||
}
|
||||
|
||||
|
||||
*/
|
||||
def compileTemplate(templateFile: String, rootDir: Option[File] = None, engine: Option[TemplateEngine] = None): (String, (TemplateEngine, Template)) = {
|
||||
val engine = new TemplateEngine(rootDir orElse Some(new File(".")))
|
||||
val srcName = config.templateDir + "/" + templateFile
|
||||
@ -573,7 +573,6 @@ class Codegen(config: CodegenConfig) {
|
||||
"models" -> allModels,
|
||||
"apiVersion" -> apiVersion) ++ config.additionalParams
|
||||
|
||||
println(pretty(render(parse(write(data)))))
|
||||
val outputFiles = config.supportingFiles map { file =>
|
||||
val supportingFile = file._1
|
||||
val outputDir = file._2
|
||||
@ -615,7 +614,7 @@ println(pretty(render(parse(write(data)))))
|
||||
engine.compiler.shutdown()
|
||||
outputFiles
|
||||
}
|
||||
|
||||
/*
|
||||
final def writeSupportingClasses(
|
||||
apis: Map[(String, String), List[(String, Operation)]],
|
||||
models: Map[String, Model],
|
||||
@ -722,7 +721,7 @@ println(pretty(render(parse(write(data)))))
|
||||
|
||||
writeSupportingClasses(apis, models, apiVersion, rootDir, dataF)
|
||||
}
|
||||
|
||||
*/
|
||||
protected def isListType(dt: String) = isCollectionType(dt, "List") || isCollectionType(dt, "Array") || isCollectionType(dt, "Set")
|
||||
|
||||
protected def isMapType(dt: String) = isCollectionType(dt, "Map")
|
||||
|
@ -114,7 +114,7 @@ object ScalaAsyncClientGenerator extends App {
|
||||
}
|
||||
|
||||
class AsyncClientCodegen(clientName: String, config: CodegenConfig, rootDir: Option[File] = None) extends Codegen(config) {
|
||||
|
||||
/*
|
||||
override def writeSupportingClasses(apis: Map[(String, String), List[(String, Operation)]],
|
||||
models: Map[String, Model], apiVersion: String): Seq[File] = {
|
||||
|
||||
@ -177,6 +177,7 @@ class AsyncClientCodegen(clientName: String, config: CodegenConfig, rootDir: Opt
|
||||
val template = eng.compile(TemplateSource.fromText(resourceName,Source.fromInputStream(is).mkString))
|
||||
(resourceName, eng -> template)
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
class ScalaAsyncClientGenerator(cfg: SwaggerGenConfig) extends BasicGenerator {
|
||||
@ -308,30 +309,29 @@ class ScalaAsyncClientGenerator(cfg: SwaggerGenConfig) extends BasicGenerator {
|
||||
val allModels = new mutable.HashMap[String, Model]
|
||||
val operations = extractApiOperations(apis, allModels)
|
||||
val operationMap = groupOperationsToFiles(operations)
|
||||
val modelBundle = prepareModelMap(allModels.toMap)
|
||||
val modelFiles = bundleToSource(modelBundle, modelTemplateFiles.toMap)
|
||||
|
||||
modelFiles.map(m => {
|
||||
val filename = m._1
|
||||
val modelMap = prepareModelMap(allModels.toMap)
|
||||
|
||||
val modelFileContents = writeFiles(modelMap, modelTemplateFiles.toMap)
|
||||
val modelFiles = new ListBuffer[File]()
|
||||
|
||||
for((filename, contents) <- modelFileContents) {
|
||||
val file = new java.io.File(filename)
|
||||
modelFiles += file
|
||||
file.getParentFile().mkdirs
|
||||
|
||||
val fw = new FileWriter(filename, false)
|
||||
fw.write(m._2 + "\n")
|
||||
fw.write(contents + "\n")
|
||||
fw.close()
|
||||
println("wrote model " + filename)
|
||||
})
|
||||
|
||||
|
||||
}
|
||||
|
||||
val apiBundle = prepareApiBundle(operationMap.toMap)
|
||||
val apiFiles = bundleToSource(apiBundle, apiTemplateFiles.toMap)
|
||||
val apiInfo = writeFiles(apiBundle, apiTemplateFiles.toMap)
|
||||
val apiFiles = new ListBuffer[File]()
|
||||
|
||||
apiFiles.map(m => {
|
||||
apiInfo.map(m => {
|
||||
val filename = m._1
|
||||
|
||||
val file = new java.io.File(filename)
|
||||
apiFiles += file
|
||||
file.getParentFile().mkdirs
|
||||
|
||||
val fw = new FileWriter(filename, false)
|
||||
@ -340,7 +340,8 @@ class ScalaAsyncClientGenerator(cfg: SwaggerGenConfig) extends BasicGenerator {
|
||||
println("wrote api " + filename)
|
||||
})
|
||||
|
||||
codegen.writeSupportingClasses(operationMap, allModels.toMap, doc.apiVersion)
|
||||
codegen.writeSupportingClasses2(apiBundle, allModels.toMap, doc.apiVersion) ++
|
||||
modelFiles ++ apiFiles
|
||||
}
|
||||
|
||||
|
||||
@ -381,6 +382,7 @@ class ScalaAsyncClientGenerator(cfg: SwaggerGenConfig) extends BasicGenerator {
|
||||
/**
|
||||
* creates a map of models and properties needed to write source
|
||||
*/
|
||||
/*
|
||||
override def prepareModelMap(models: Map[String, Model]): List[Map[String, AnyRef]] = {
|
||||
for {
|
||||
(name, schema) <- (models -- defaultIncludes).toList
|
||||
@ -439,7 +441,7 @@ class ScalaAsyncClientGenerator(cfg: SwaggerGenConfig) extends BasicGenerator {
|
||||
fw.close()
|
||||
println("wrote " + filename)
|
||||
}
|
||||
|
||||
*/
|
||||
override def groupOperationsToFiles(operations: List[(String, String, Operation)]): Map[(String, String), List[(String, Operation)]] = {
|
||||
val opMap = new mutable.HashMap[(String, String), mutable.ListBuffer[(String, Operation)]]
|
||||
for ((basePath, apiPath, operation) <- operations) {
|
||||
|
@ -265,7 +265,7 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
queryParam("allowableValues") should be (Some("LIST[available,pending,sold]"))
|
||||
}
|
||||
|
||||
ignore should "create an api file" in {
|
||||
it should "create an api file" in {
|
||||
implicit val basePath = "http://localhost:8080/api"
|
||||
val codegen = new Codegen(config)
|
||||
val resourceListing = ResourceExtractor.fetchListing("src/test/resources/petstore-1.1/resources.json", None)
|
||||
@ -281,8 +281,6 @@ class BasicScalaGeneratorTest extends FlatSpec with ShouldMatchers {
|
||||
val operations = config.extractApiOperations(List(petApi), allModels)
|
||||
|
||||
val operationMap = config.groupOperationsToFiles(operations)
|
||||
// val bundle = config.prepareApiBundle(apiMap)
|
||||
// val apiFiles = config.bundleToSource(bundle, config.apiTemplateFiles.toMap)
|
||||
|
||||
val apiBundle = config.prepareApiBundle(operationMap.toMap)
|
||||
val apiInfo = config.writeFiles(apiBundle, config.apiTemplateFiles.toMap)
|
||||
|
Loading…
x
Reference in New Issue
Block a user