Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@ public void processOpts() {
supportingFiles.add(new SupportingFile("ServletApp.mustache", sourceFolderByPackage(appPackage), "ServletApp.scala"));
supportingFiles.add(new SupportingFile("project/build.properties", "project", "build.properties"));
supportingFiles.add(new SupportingFile("project/plugins.sbt", "project", "plugins.sbt"));
supportingFiles.add(new SupportingFile("scalafmt.mustache", "", ".scalafmt.conf"));
supportingFiles.add(new SupportingFile("sbt", "", "sbt"));

additionalProperties.put("appName", appName);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.0.1")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6")
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version=3.10.6
runner.dialect = scala212
project {
git = false
excludeFilters = [
scalafmt-benchmarks/src/resources,
sbt-test
bin/issue
]
layout = StandardConvention
}
align {
preset = none
stripMargin = true
}
binPack {
importSelectors = fold
}
newlines {
avoidForSimpleOverflow = all
ignoreInSyntax = false
source = fold
}
rewrite {
rules = [
AvoidInfix,
Imports,
RedundantBraces,
RedundantParens,
SortModifiers,
]
imports {
selectors = fold
removeRedundantSelectors = true
sort = ascii
groups = [
["org\\.scalafmt\\..*"],
["scala\\.meta\\..*", "org\\.scalameta\\..*"],
["sbt\\..*"],
["java.?\\..*"],
["scala\\..*"],
["org\\..*"],
["com\\..*"],
]
}
redundantBraces {
preset = all
oneStatApply {
parensMaxSpan = 300
bracesMinSpan = 300
}
}
redundantParens {
preset = all
}
sortModifiers.preset = styleGuide
trailingCommas.style = "always"
}
21 changes: 21 additions & 0 deletions samples/server/petstore/scalatra/.openapi-generator/FILES
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
.gitignore
.scalafmt.conf
README.md
build.sbt
project/build.properties
project/plugins.sbt
sbt
src/main/resources/logback.xml
src/main/scala/org/openapitools/JettyMain.scala
src/main/scala/org/openapitools/ScalatraBootstrap.scala
src/main/scala/org/openapitools/app/ServletApp.scala
src/main/scala/org/openapitools/server/api/PetApi.scala
src/main/scala/org/openapitools/server/api/StoreApi.scala
src/main/scala/org/openapitools/server/api/UserApi.scala
src/main/scala/org/openapitools/server/model/ApiResponse.scala
src/main/scala/org/openapitools/server/model/Category.scala
src/main/scala/org/openapitools/server/model/Order.scala
src/main/scala/org/openapitools/server/model/Pet.scala
src/main/scala/org/openapitools/server/model/Tag.scala
src/main/scala/org/openapitools/server/model/User.scala
src/main/webapp/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
5.0.0-SNAPSHOT
7.22.0-SNAPSHOT
58 changes: 58 additions & 0 deletions samples/server/petstore/scalatra/.scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
version=3.10.6
runner.dialect = scala212
project {
git = false
excludeFilters = [
scalafmt-benchmarks/src/resources,
sbt-test
bin/issue
]
layout = StandardConvention
}
align {
preset = none
stripMargin = true
}
binPack {
importSelectors = fold
}
newlines {
avoidForSimpleOverflow = all
ignoreInSyntax = false
source = fold
}
rewrite {
rules = [
AvoidInfix,
Imports,
RedundantBraces,
RedundantParens,
SortModifiers,
]
imports {
selectors = fold
removeRedundantSelectors = true
sort = ascii
groups = [
["org\\.scalafmt\\..*"],
["scala\\.meta\\..*", "org\\.scalameta\\..*"],
["sbt\\..*"],
["java.?\\..*"],
["scala\\..*"],
["org\\..*"],
["com\\..*"],
]
}
redundantBraces {
preset = all
oneStatApply {
parensMaxSpan = 300
bracesMinSpan = 300
}
}
redundantParens {
preset = all
}
sortModifiers.preset = styleGuide
trailingCommas.style = "always"
}
4 changes: 2 additions & 2 deletions samples/server/petstore/scalatra/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.openapitools"
name := "scalatra-sample"
version := "0.1.0-SNAPSHOT"
name := "org.openapitools-openapi-server"
version := "1.0.0"
scalaVersion := "2.12.20"

mainClass in assembly := Some("JettyMain")
Expand Down
1 change: 1 addition & 0 deletions samples/server/petstore/scalatra/project/plugins.sbt
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
addSbtPlugin("com.eed3si9n" % "sbt-assembly" % "0.14.6")
addSbtPlugin("com.earldouglas" % "xsbt-web-plugin" % "4.0.1")
addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.8.2")
addSbtPlugin("org.scalameta" % "sbt-scalafmt" % "2.5.6")
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* Contact: team@openapitools.org
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*/

package org.openapitools
import org.eclipse.jetty.server._
import org.eclipse.jetty.webapp.WebAppContext
import org.scalatra.servlet.ScalatraListener

object JettyMain {

object conf {
val port = sys.env.get("PORT") map (_.toInt) getOrElse (8080)
val stopTimeout = sys.env.get("STOP_TIMEOUT") map (_.toInt) getOrElse (5000)
val connectorIdleTimeout = sys.env.get("CONNECTOR_IDLE_TIMEOUT") map (_.toInt) getOrElse (90000)
val webapp = sys.env.get("PUBLIC") getOrElse "webapp"
val contextPath = sys.env.get("CONTEXT_PATH") getOrElse "/"
}

def main(args: Array[String]) = {
val server: Server = new Server
println("starting jetty")

server setStopTimeout conf.stopTimeout
//server setDumpAfterStart true
server setStopAtShutdown true

val httpConfig = new HttpConfiguration()
httpConfig setSendDateHeader true
httpConfig setSendServerVersion false

val connector = new NetworkTrafficServerConnector(server, new HttpConnectionFactory(httpConfig))
connector setPort conf.port
connector setSoLingerTime 0
connector setIdleTimeout conf.connectorIdleTimeout
server addConnector connector

val webapp = conf.webapp
val webApp = new WebAppContext
webApp setContextPath conf.contextPath
webApp setResourceBase conf.webapp
webApp setEventListeners Array(new ScalatraListener)
webApp.setInitParameter(ScalatraListener.LifeCycleKey, classOf[ScalatraBootstrap].getName)

server setHandler webApp

server.start()
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* Contact: team@openapitools.org
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*/

package org.openapitools
import org.openapitools.server.api._
import org.openapitools.app.{ ResourcesApp, OpenAPIApp }
import javax.servlet.ServletContext
import org.scalatra.LifeCycle

class ScalatraBootstrap extends LifeCycle {
implicit val openapi = new OpenAPIApp

override def init(context: ServletContext) {
try {
context mount (new PetApi, "/v2/Pet/*")
context mount (new StoreApi, "/v2/Store/*")
context mount (new UserApi, "/v2/User/*")
context mount (new ResourcesApp, "/api-docs/*")
} catch {
case e: Throwable => e.printStackTrace()
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* OpenAPI Petstore
* This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
*
* The version of the OpenAPI document: 1.0.0
* Contact: team@openapitools.org
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
*/


package org.openapitools.app

import org.scalatra.swagger.{ ApiInfo, SwaggerWithAuth, Swagger }
import org.scalatra.swagger.{ JacksonSwaggerBase, Swagger }
import org.scalatra.ScalatraServlet
import org.json4s.{ DefaultFormats, Formats }

class ResourcesApp(implicit protected val swagger: OpenAPIApp)
extends ScalatraServlet with JacksonSwaggerBase {
before() {
response.headers += ("Access-Control-Allow-Origin" -> "*")
}
}

class OpenAPIApp extends Swagger(apiInfo = OpenAPIInfo.apiInfo, apiVersion = "1.0.0", swaggerVersion = Swagger.SpecVersion)

object OpenAPIInfo {
val apiInfo = ApiInfo(
"""OpenAPI Petstore""",
"""This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.""",
"""http://org.openapitools""",
"""team@openapitools.org""",
"""Apache-2.0""",
"""https://www.apache.org/licenses/LICENSE-2.0.html""")
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

package org.openapitools.server.api

import java.time.OffsetDateTime
import org.openapitools.server.model.User

import java.io.File
Expand Down
Loading