Skip to content

Commit

Permalink
Upgrade to play 2.9 / scala 3 (#937)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbryzek authored Jul 11, 2024
1 parent 0ddc84b commit ad8b17c
Show file tree
Hide file tree
Showing 203 changed files with 2,453 additions and 1,000 deletions.
20 changes: 10 additions & 10 deletions .apibuilder/.tracked_files
Original file line number Diff line number Diff line change
Expand Up @@ -4,39 +4,39 @@ apicollective:
anorm_2_8_parsers:
- api/app/generated/ApicollectiveApibuilderApiV0Conversions.scala
- api/app/generated/ApicollectiveApibuilderApiV0Parsers.scala
play_2_8_client:
play_2_9_scala_3_client:
- generated/app/ApicollectiveApibuilderApiV0Client.scala
play_2_x_routes:
- api/conf/routes
apibuilder-api-json:
play_2_x_json:
play_2_x_scala_3_json:
- core/src/main/scala/core/generated/ApicollectiveApibuilderApiJsonV0Models.scala
apibuilder-common:
anorm_2_8_parsers:
- api/app/generated/ApicollectiveApibuilderCommonV0Conversions.scala
- api/app/generated/ApicollectiveApibuilderCommonV0Parsers.scala
play_2_8_client:
- generated/app/ApicollectiveApibuilderCommonV0Client.scala
play_2_8_mock_client:
- generated/app/ApicollectiveApibuilderCommonV0MockClient.scala
play_2_9_scala_3_client:
- generated/app/ApicollectiveApibuilderCommonV0Client.scala
apibuilder-generator:
anorm_2_8_parsers:
- api/app/generated/ApicollectiveApibuilderGeneratorV0Conversions.scala
- api/app/generated/ApicollectiveApibuilderGeneratorV0Parsers.scala
play_2_8_client:
- generated/app/ApicollectiveApibuilderGeneratorV0Client.scala
play_2_8_mock_client:
- generated/app/ApicollectiveApibuilderGeneratorV0MockClient.scala
play_2_9_scala_3_client:
- generated/app/ApicollectiveApibuilderGeneratorV0Client.scala
apibuilder-spec:
anorm_2_8_parsers:
- api/app/generated/ApicollectiveApibuilderSpecV0Conversions.scala
- api/app/generated/ApicollectiveApibuilderSpecV0Parsers.scala
play_2_8_client:
- generated/app/ApicollectiveApibuilderSpecV0Client.scala
play_2_8_mock_client:
- generated/app/ApicollectiveApibuilderSpecV0MockClient.scala
play_2_9_scala_3_client:
- generated/app/ApicollectiveApibuilderSpecV0Client.scala
apibuilder-task:
play_2_8_client:
- generated/app/ApicollectiveApibuilderTaskV0Client.scala
play_2_8_mock_client:
- generated/app/ApicollectiveApibuilderTaskV0MockClient.scala
play_2_9_scala_3_client:
- generated/app/ApicollectiveApibuilderTaskV0Client.scala
13 changes: 7 additions & 6 deletions .apibuilder/config
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,31 @@ code:
apibuilder-api:
version: latest
generators:
play_2_8_client: generated/app
play_2_9_scala_3_client: generated/app
play_2_x_routes: api/conf/routes
apibuilder-api-json:
version: latest
generators:
play_2_x_json: core/src/main/scala/core/generated
play_2_x_scala_3_json: core/app/generated
apibuilder-spec:
version: latest
generators:
play_2_8_client: generated/app
play_2_x_standalone_json: lib/src/main/scala/generated
play_2_9_scala_3_client: generated/app
play_2_8_mock_client: generated/app
apibuilder-common:
version: latest
generators:
play_2_8_client: generated/app
play_2_9_scala_3_client: generated/app
play_2_8_mock_client: generated/app
apibuilder-generator:
version: latest
generators:
play_2_8_client: generated/app
play_2_9_scala_3_client: generated/app
play_2_8_mock_client: generated/app
apibuilder-task:
version: latest
generators:
play_2_8_client: generated/app
play_2_9_scala_3_client: generated/app
play_2_8_mock_client: generated/app

2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
strategy:
matrix:
java: [ '17' ]
scala: [ '2.13.11' ]
scala: [ '3.4.2' ]
steps:
- uses: actions/checkout@v2
- name: Set up JDK
Expand Down
9 changes: 9 additions & 0 deletions .scalafmt.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
version = 3.5.9
runner.dialect=scala213
maxColumn = 120
continuationIndent.callSite = 2
continuationIndent.defnSite = 2
continuationIndent.ctorSite = 2
continuationIndent.extendSite = 2
align.preset = none
project.excludePaths = [ "glob:**/generated/**" ]
23 changes: 0 additions & 23 deletions .travis.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Build Status](https://travis-ci.org/apicollective/apibuilder.svg?branch=main)](https://travis-ci.org/apicollective/apibuilder)

apibuilder
API Builder
==========

Simple, Comprehensive Tooling for Modern APIs.
Expand Down
2 changes: 1 addition & 1 deletion TODO
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ inserting duplicate records.
API changes - generate history of field reordering

[warn] /web/apidoc/api/app/db/generators/ServicesDao.scala:118: method apply in trait WithResult is deprecated: Use [[fold]], [[foldWhile]] or [[withResult]] instead, which manages resources and memory
[warn] SQL(sql).on(bind: _*)().toList.map { fromRow(_) }.toSeq
[warn] SQL(sql).on(bind*)().toList.map { fromRow(_) }.toSeq

Consider supporting (from swagger):
- parameter locations: header, cookie
Expand Down
8 changes: 4 additions & 4 deletions api/app/controllers/ApiBuilderController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ class AnonymousActionBuilder @Inject()(

def invokeBlock[A](
request: Request[A],
block: (AnonymousRequest[A]
) => Future[Result]): Future[Result] = {
block: AnonymousRequest[A] => Future[Result]
): Future[Result] = {
block(
AnonymousRequest(
user = requestAuthenticationUtil.user(request.headers),
Expand All @@ -149,8 +149,8 @@ class IdentifiedActionBuilder @Inject()(

def invokeBlock[A](
request: Request[A],
block: (IdentifiedRequest[A]
) => Future[Result]): Future[Result] = {
block: IdentifiedRequest[A] => Future[Result]
): Future[Result] = {
requestAuthenticationUtil.user(request.headers) match {
case None => Future.successful(Results.Unauthorized)
case Some(user) => block(IdentifiedRequest(user, request))
Expand Down
8 changes: 4 additions & 4 deletions api/app/controllers/Attributes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Attributes @Inject() (
name: Option[String],
limit: Long = 25,
offset: Long = 0
) = Anonymous { _ =>
): Action[AnyContent] = Anonymous { _ =>
val attributes = attributesDao.findAll(
guid = guid,
name = name,
Expand All @@ -30,14 +30,14 @@ class Attributes @Inject() (
Ok(Json.toJson(attributes))
}

def getByName(name: String) = Action { _ =>
def getByName(name: String): Action[AnyContent] = Action { _ =>
attributesDao.findByName(name) match {
case None => NotFound
case Some(attribute) => Ok(Json.toJson(attribute))
}
}

def post() = Identified(parse.json) { request =>
def post(): Action[JsValue] = Identified(parse.json) { request =>
request.body.validate[AttributeForm] match {
case e: JsError => {
UnprocessableEntity(Json.toJson(Validation.invalidJson(e)))
Expand All @@ -57,7 +57,7 @@ class Attributes @Inject() (
}
}

def deleteByName(name: String) = Identified { request =>
def deleteByName(name: String): Action[AnyContent] = Identified { request =>
attributesDao.findByName(name) match {
case None => {
NotFound
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/Authentications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Authentications @Inject() (
usersDao: UsersDao
) extends ApiBuilderController {

def getSessionById(sessionId: String) = Anonymous { _ =>
def getSessionById(sessionId: String): Action[AnyContent] = Anonymous { _ =>
sessionsDao.findById(sessionId) match {
case None => NotFound
case Some(session) => {
Expand Down
6 changes: 4 additions & 2 deletions api/app/controllers/BatchDownloadApplications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ package controllers

import cats.data.Validated.{Invalid, Valid}
import io.apibuilder.api.v0.models.BatchDownloadApplicationsForm
import io.apibuilder.api.v0.models.json._
import io.apibuilder.api.v0.models.json.*

import javax.inject.{Inject, Singleton}
import lib.Validation
import play.api.libs.json.Json
import play.api.mvc.Action
import services.BatchDownloadApplicationsService

@Singleton
Expand All @@ -14,7 +16,7 @@ class BatchDownloadApplications @Inject() (
service: BatchDownloadApplicationsService,
) extends ApiBuilderController {

def post(orgKey: String) = Anonymous(parse.json[BatchDownloadApplicationsForm]) { request =>
def post(orgKey: String): Action[BatchDownloadApplicationsForm] = Anonymous(parse.json[BatchDownloadApplicationsForm]) { request =>
service.process(request.authorization, orgKey, request.body) match {
case Valid(result) => Created(Json.toJson(result))
case Invalid(errors) => Conflict(Json.toJson(Validation.errors(errors)))
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/Changes.scala
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Changes @Inject() (
`type`: Option[String],
limit: Long = 25,
offset: Long = 0
) = Anonymous { request =>
): Action[AnyContent] = Anonymous { request =>
val changes = changesDao.findAll(
request.authorization,
organizationKey = orgKey,
Expand Down
4 changes: 2 additions & 2 deletions api/app/controllers/Code.scala
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class Code @Inject() (

@nowarn
private def _invoke(
request: AnonymousRequest[_],
request: AnonymousRequest[?],
params: CodeParams,
data: InvocationFormData,
generatorKey: String
Expand Down Expand Up @@ -191,7 +191,7 @@ class Code @Inject() (
}

private def invocationForm[T](
request: AnonymousRequest[_],
request: AnonymousRequest[?],
params: CodeParams
): Either[Seq[String], InvocationFormData] = {
versionsDao.findVersion(request.authorization, params.orgKey, params.applicationKey, params.versionName)
Expand Down
4 changes: 2 additions & 2 deletions api/app/controllers/Domains.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class Domains @Inject() (
organizationDomainsDao: OrganizationDomainsDao
) extends ApiBuilderController {

def post(orgKey: String) = Identified(parse.json) { request =>
def post(orgKey: String): Action[JsValue] = Identified(parse.json) { request =>
withOrgAdmin(request.user, orgKey) { org =>
request.body.validate[Domain] match {
case e: JsError => {
Expand All @@ -40,7 +40,7 @@ class Domains @Inject() (
}
}

def deleteByName(orgKey: String, name: String) = Identified { request =>
def deleteByName(orgKey: String, name: String): Action[AnyContent] = Identified { request =>
withOrgAdmin(request.user, orgKey) { org =>
org.domains.find(_.name == name).foreach { domain =>
organizationDomainsDao.findAll(organizationGuid = Some(org.guid), domain = Some(domain.name)).foreach { orgDomain =>
Expand Down
8 changes: 4 additions & 4 deletions api/app/controllers/GeneratorServices.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class GeneratorServices @Inject() (
generatorKey: Option[String],
limit: Long = 25,
offset: Long = 0
) = Anonymous { request =>
): Action[AnyContent] = Anonymous { request =>
val services = servicesDao.findAll(
request.authorization,
guid = guid,
Expand All @@ -39,14 +39,14 @@ class GeneratorServices @Inject() (
Ok(Json.toJson(services))
}

def getByGuid(guid: UUID) = Anonymous { request =>
def getByGuid(guid: UUID): Action[AnyContent] = Anonymous { request =>
servicesDao.findByGuid(request.authorization, guid) match {
case None => NotFound
case Some(service) => Ok(Json.toJson(service))
}
}

def post() = Identified(parse.json) { request =>
def post(): Action[JsValue] = Identified(parse.json) { request =>
request.body.validate[GeneratorServiceForm] match {
case e: JsError => {
Conflict(Json.toJson(Validation.invalidJson(e)))
Expand Down Expand Up @@ -78,7 +78,7 @@ class GeneratorServices @Inject() (

def deleteByGuid(
guid: UUID
) = Identified { request =>
): Action[AnyContent] = Identified { request =>
servicesDao.findByGuid(request.authorization, guid) match {
case None => {
NotFound
Expand Down
4 changes: 2 additions & 2 deletions api/app/controllers/Items.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Items @Inject() (
q: Option[String],
limit: Long = 25,
offset: Long = 0
) = Anonymous { request =>
): Action[AnyContent] = Anonymous { request =>
val items = itemsDao.findAll(
request.authorization,
q = q,
Expand All @@ -29,7 +29,7 @@ class Items @Inject() (

def getByGuid(
guid: UUID
) = Anonymous { request =>
): Action[AnyContent] = Anonymous { request =>
itemsDao.findByGuid(request.authorization, guid) match {
case None => NotFound
case Some(item) => Ok(Json.toJson(item))
Expand Down
3 changes: 1 addition & 2 deletions api/app/controllers/MembershipRequests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ class MembershipRequests @Inject() (
case e: JsError => {
Conflict(Json.toJson(Validation.error(e.toString)))
}
case s: JsSuccess[MembershipRequestForm] => {
val form = s.get
case JsSuccess(form: MembershipRequestForm, _) => {
organizationsDao.findByGuid(request.authorization, form.org_guid) match {
case None => {
Conflict(Json.toJson(Validation.error("Organization not found or not authorized to make changes to this org")))
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/PasswordResetRequests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class PasswordResetRequests @Inject() (
usersDao: UsersDao
) extends ApiBuilderController {

def post() = Anonymous(parse.json) { request =>
def post(): Action[JsValue] = Anonymous(parse.json) { request =>
request.body.validate[PasswordResetRequest] match {
case e: JsError => {
Conflict(Json.toJson(Validation.invalidJson(e)))
Expand Down
2 changes: 1 addition & 1 deletion api/app/controllers/PasswordResets.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PasswordResets @Inject() (
userPasswordsDao: UserPasswordsDao
) extends ApiBuilderController {

def post() = Anonymous(parse.json) { request =>
def post(): Action[JsValue] = Anonymous(parse.json) { request =>
request.body.validate[PasswordReset] match {
case e: JsError => {
Conflict(Json.toJson(Validation.invalidJson(e)))
Expand Down
9 changes: 4 additions & 5 deletions api/app/controllers/Subscriptions.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
package controllers

import db.SubscriptionsDao
import lib.Validation
import io.apibuilder.api.v0.models.{Publication, SubscriptionForm}
import io.apibuilder.api.v0.models.json._
import io.apibuilder.api.v0.models.{Publication, SubscriptionForm}
import lib.Validation
import models.SubscriptionModel

import javax.inject.{Inject, Singleton}
import play.api.mvc._
import play.api.libs.json._
import play.api.mvc._

import java.util.UUID
import javax.inject.{Inject, Singleton}

@Singleton
class Subscriptions @Inject() (
Expand Down
Loading

0 comments on commit ad8b17c

Please sign in to comment.