Skip to content
This repository was archived by the owner on Oct 14, 2021. It is now read-only.
Merged
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 @@ -3,6 +3,7 @@ package net.adoptopenjdk.api.v3
import net.adoptopenjdk.api.v3.dataSources.APIDataStore
import net.adoptopenjdk.api.v3.routes.AssetsResource
import net.adoptopenjdk.api.v3.routes.BinaryResource
import net.adoptopenjdk.api.v3.routes.V1Route
import net.adoptopenjdk.api.v3.routes.VersionResource
import net.adoptopenjdk.api.v3.routes.info.AvailableReleasesResource
import net.adoptopenjdk.api.v3.routes.info.PlatformsResource
Expand Down Expand Up @@ -30,7 +31,7 @@ const val DESCRIPTION = "<li><strong>NOTICE:</strong> AdoptOpenJDK API v1 Has no
Server(url = "https://staging-api.adoptopenjdk.net")
],
info = Info(title = "v3", version = "3.0.0", description = DESCRIPTION))
@ApplicationPath("/v3")
@ApplicationPath("/")
class V3 : Application() {

private val resourceClasses: Set<Class<out Any>>
Expand All @@ -47,6 +48,7 @@ class V3 : Application() {
APIDataStore.getAdoptRepos()

resourceClasses = setOf(
V1Route::class.java,
AssetsResource::class.java,
BinaryResource::class.java,
AvailableReleasesResource::class.java,
Expand All @@ -65,3 +67,4 @@ class V3 : Application() {
return resourceClasses
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import kotlin.math.min


@Tag(name = "Assets")
@Path("/assets/")
@Path("/v3/assets/")
@Produces(MediaType.APPLICATION_JSON)
class AssetsResource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import javax.ws.rs.core.Response


@Tag(name = "Binary")
@Path("/binary/")
@Path("/v3/binary/")
@Produces(MediaType.APPLICATION_JSON)
class BinaryResource {

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package net.adoptopenjdk.api.v3.routes

import org.eclipse.microprofile.openapi.annotations.Operation
import org.eclipse.microprofile.openapi.annotations.media.Schema
import javax.ws.rs.GET
import javax.ws.rs.Path
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response

@Path("/v1/")
@Schema(hidden = true)
@Produces(MediaType.TEXT_PLAIN)
class V1Route {

//Cant find a way to match nothing and something in the same request, so need 2
@GET
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Document why this sucks

@Schema(hidden = true)
@Path("/{ignore: .*}")
@Operation(hidden = true)
fun get(): Response = reject()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better names to expose the suckage


@GET
@Schema(hidden = true)
@Path("/")
@Operation(hidden = true)
fun getRoot(): Response = reject()


private fun reject(): Response {
return Response
.status(Response.Status.GONE)
.entity("REMOVED: V1 has now been removed, please see https://api.adoptopenjdk.net for the latest version")
.build()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType

@Tag(name = "Version")
@Path("/version/")
@Path("/v3/version/")
@Produces(MediaType.APPLICATION_JSON)
class VersionResource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType

@Tag(name = "Release Info")
@Path("/info/")
@Path("/v3/info/")
@Produces(MediaType.APPLICATION_JSON)
class AvailableReleasesResource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType

@Tag(name = "Release Info")
@Path("/info/")
@Path("/v3/info/")
@Produces(MediaType.APPLICATION_JSON)
class PlatformsResource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType

@Tag(name = "Release Info")
@Path("/info")
@Path("/v3/info")
@Produces(MediaType.APPLICATION_JSON)
class ReleaseListResource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType

@Tag(name = "Release Info")
@Path("/info")
@Path("/v3/info")
@Produces(MediaType.APPLICATION_JSON)
class VariantsResource {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import javax.ws.rs.core.MediaType
import javax.ws.rs.core.Response


@Path("/stats/downloads")
@Path("/v3/stats/downloads")
@Produces(MediaType.APPLICATION_JSON)
@Schema(hidden = true)
class DownloadStatsResource {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package net.adoptopenjdk.api

import io.quarkus.test.junit.QuarkusTest
import io.restassured.RestAssured
import org.junit.jupiter.api.Test
import javax.ws.rs.core.Response

@QuarkusTest
class V1RouteTest : BaseTest() {
@Test
fun v1ReturnsGone() {
listOf("/v1",
"/v1/",
"/v1/foo",
"/v1/foo/bar")
.forEach({ route ->
RestAssured.given()
.`when`()
.get(route)
.then()
.statusCode(Response.Status.GONE.statusCode)
})
}

}