Skip to content

Commit

Permalink
Merge pull request #1 from softwaremill/pr-for-review
Browse files Browse the repository at this point in the history
Revert "remove everything"
  • Loading branch information
ghostbuster91 authored Jul 17, 2020
2 parents 64864bd + c879f91 commit 4e8a611
Show file tree
Hide file tree
Showing 7 changed files with 751 additions and 0 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
# sttp-openapi example
36 changes: 36 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name := "sttp-openapi-generator-example"

version := "0.1"

scalaVersion := "2.13.2"

lazy val petstoreApi: Project = project
.in(file("petstore-api"))
.settings(
openApiInputSpec := s"${baseDirectory.value.getPath}/petstore.yaml",
openApiGeneratorName := "scala-sttp",
//We can't use src_managed because there is no option to tell openapi-generator to generate files into different folder than src
//see https://github.com/OpenAPITools/openapi-generator/issues/6685 for more details
openApiOutputDir := baseDirectory.value.name,
//Below setting is needed to configure generator not to generate other files besides src/main/scala
openApiIgnoreFileOverride := s"${baseDirectory.in(ThisBuild).value.getPath}/openapi-ignore-file",
libraryDependencies ++= Seq(
"com.softwaremill.sttp.client" %% "core" % "2.2.0",
"com.softwaremill.sttp.client" %% "json4s" % "2.2.0",
"org.json4s" %% "json4s-jackson" % "3.6.8"
),
//We can't use sourceGenerators because this requires all files to compile and openapi-generator generates
//some additional metadata files which breaks compilation.
//see https://github.com/OpenAPITools/openapi-generator/issues/6685 for more details
(compile in Compile) := ((compile in Compile) dependsOn openApiGenerate).value,
//As we don't generate files into src_managed we have to do cleaning by our own
cleanFiles += baseDirectory.value / "src"
)

lazy val core = project
.in(file("core"))
.dependsOn(petstoreApi)

lazy val rootProject = project
.in(file("."))
.aggregate(petstoreApi, core)
14 changes: 14 additions & 0 deletions core/src/main/scala/sttp/example/Main.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package sttp.example

import org.openapitools.client.api.StoreApi
import org.openapitools.client.core.{ApiKeyValue, SttpSerializer}
import sttp.client.HttpURLConnectionBackend

object Main {
def main(args: Array[String]): Unit = {
implicit val serializer: SttpSerializer = new SttpSerializer()
implicit val apiKeyValue = ApiKeyValue("")
implicit val backend = HttpURLConnectionBackend()
println(StoreApi().getInventory().send())
}
}
3 changes: 3 additions & 0 deletions openapi-ignore-file
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
*
**/*
!**/src/main/scala/**/*
Loading

0 comments on commit 4e8a611

Please sign in to comment.