Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to play 2.9 / scala 3 #937

Merged
merged 97 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
3e87685
wip
mbryzek Jul 2, 2024
9583ca4
wip
mbryzek Jul 2, 2024
620156c
wip
mbryzek Jul 2, 2024
db18e08
wip
mbryzek Jul 2, 2024
40ecdef
wip
mbryzek Jul 2, 2024
fc4c43f
wip
mbryzek Jul 2, 2024
7a888de
wip
mbryzek Jul 2, 2024
d775200
wip
mbryzek Jul 2, 2024
0753f53
wip
mbryzek Jul 2, 2024
69c8135
wip
mbryzek Jul 3, 2024
5319fb5
wip
mbryzek Jul 3, 2024
73836af
wip
mbryzek Jul 3, 2024
c9a76bb
wip
mbryzek Jul 3, 2024
0359017
wip
mbryzek Jul 3, 2024
26352f5
wip
mbryzek Jul 3, 2024
351d9f7
wip
mbryzek Jul 3, 2024
8d65659
wip
mbryzek Jul 3, 2024
888661a
wip
mbryzek Jul 3, 2024
0e07bb2
wip
mbryzek Jul 3, 2024
6d82565
wip
mbryzek Jul 3, 2024
2de4a96
wip
mbryzek Jul 3, 2024
6a4735e
wip
mbryzek Jul 4, 2024
a71d364
wip
mbryzek Jul 4, 2024
e566075
wip
mbryzek Jul 4, 2024
ab1374b
wip
mbryzek Jul 4, 2024
8800410
wip
mbryzek Jul 4, 2024
ee4cd33
wip
mbryzek Jul 4, 2024
afce900
wip
mbryzek Jul 4, 2024
33f3bb2
wip
mbryzek Jul 4, 2024
a97dbbc
wip
mbryzek Jul 4, 2024
e0bdc1a
wip
mbryzek Jul 4, 2024
1e585cf
wip
mbryzek Jul 4, 2024
047e210
wip
mbryzek Jul 4, 2024
fda16c0
wip
mbryzek Jul 4, 2024
836401f
wip
mbryzek Jul 4, 2024
032bb72
wip
mbryzek Jul 5, 2024
8ef372c
wip
mbryzek Jul 5, 2024
186b899
wip
mbryzek Jul 5, 2024
77a4db5
wip
mbryzek Jul 5, 2024
9dcfde6
wip
mbryzek Jul 5, 2024
09ff181
wip
mbryzek Jul 5, 2024
5f1b3fc
wip
mbryzek Jul 5, 2024
a546edd
wip
mbryzek Jul 5, 2024
4f7a2d1
wip
mbryzek Jul 5, 2024
3e4510f
wip
mbryzek Jul 5, 2024
709ab45
wip
mbryzek Jul 5, 2024
2c1a149
wip
mbryzek Jul 5, 2024
66eae1f
wip
mbryzek Jul 5, 2024
ad1a4e7
wip
mbryzek Jul 5, 2024
ce81f56
wip
mbryzek Jul 5, 2024
27f388f
wip
mbryzek Jul 5, 2024
600cf13
wip
mbryzek Jul 5, 2024
13c190d
wip
mbryzek Jul 5, 2024
d91e0f5
wip
mbryzek Jul 5, 2024
6db26dd
wip
mbryzek Jul 5, 2024
f5f2d5a
Revert "wip"
mbryzek Jul 5, 2024
1303202
wip
mbryzek Jul 5, 2024
736007f
wip
mbryzek Jul 5, 2024
2c08ca8
wip
mbryzek Jul 5, 2024
4d533a2
wip
mbryzek Jul 5, 2024
85e2655
wip
mbryzek Jul 5, 2024
894dac1
wip
mbryzek Jul 5, 2024
6f561d8
wip
mbryzek Jul 6, 2024
21e3e33
Revert "wip"
mbryzek Jul 6, 2024
319c6e5
wip
mbryzek Jul 6, 2024
bdbf440
wip
mbryzek Jul 6, 2024
3789f22
wip
mbryzek Jul 6, 2024
702bdb1
wip
mbryzek Jul 6, 2024
d44841a
Revert "wip"
mbryzek Jul 6, 2024
19b6bd7
wip
mbryzek Jul 6, 2024
8339b40
wip
mbryzek Jul 6, 2024
ba79b19
wip
mbryzek Jul 6, 2024
994a3b5
wip
mbryzek Jul 6, 2024
15d76b4
wip
mbryzek Jul 6, 2024
727a712
wip
mbryzek Jul 9, 2024
2f31155
wip
mbryzek Jul 9, 2024
575a79f
wip
mbryzek Jul 9, 2024
80d50d8
wip
mbryzek Jul 9, 2024
8c9cadc
wip
mbryzek Jul 9, 2024
544b071
wip
mbryzek Jul 9, 2024
9f46f92
wip
mbryzek Jul 9, 2024
68ace1b
wip
mbryzek Jul 9, 2024
258c31c
wip
mbryzek Jul 9, 2024
775e67f
wip
mbryzek Jul 9, 2024
22dd145
wip
mbryzek Jul 9, 2024
fceadfc
wip
mbryzek Jul 9, 2024
2987b15
wip
mbryzek Jul 9, 2024
cd91e1d
wip
mbryzek Jul 9, 2024
18dcbaa
wip
mbryzek Jul 9, 2024
9513eb8
wip
mbryzek Jul 9, 2024
27f81ec
wip
mbryzek Jul 9, 2024
2c5c06a
wip
mbryzek Jul 9, 2024
05c828c
wip
mbryzek Jul 9, 2024
cea3877
wip
mbryzek Jul 9, 2024
9677300
wip
mbryzek Jul 9, 2024
c77d75c
wip
mbryzek Jul 9, 2024
f6f586b
wip
mbryzek Jul 9, 2024
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
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
Loading