I am implementing a Swift Package Registry Service using swift-openapi-vapor. This service contains (among others) these two endpoints:
The OpenAPI spec for this service can be found here.
The bug is: the VaporTransport cannot distinguish between these two routes. When I hit the my server with the following URL:
http://127.0.0.1:8080/pointfreeco/swift-clocks/1.0.6.zip
then this gets parsed as a fetchReleaseMetadata route rather than a downloadSourceArchive route.
I believe the bug is here in VaporTransport.swift:
extension [Vapor.PathComponent] {
init(_ path: String) {
self = path.split(
separator: "/",
omittingEmptySubsequences: true
).map { parameter in
if parameter.first == "{", parameter.last == "}" {
return .parameter(String(parameter.dropFirst().dropLast()))
} else {
return .constant(String(parameter))
}
}
}
}
Currently the OpenAPI path /{scope}/{name}/{version}.zip is getting parsed as:
[
.parameter("scope"),
.parameter("name"),
.constant("{version}.zip")
]
I would assume that the OpenAPI path /{scope}/{name}/{version}.zip should get parsed as:
.parameter("scope"),
.parameter("name"),
.parameter("version"),
.constant(".zip"),
Is this a correct assumption?
If so, then I will put up a PR which accomplishes this.
I am implementing a Swift Package Registry Service using
swift-openapi-vapor. This service contains (among others) these two endpoints:GET /{scope}/{name}/{version}GET /{scope}/{name}/{version}.zipThe OpenAPI spec for this service can be found here.
The bug is: the
VaporTransportcannot distinguish between these two routes. When I hit the my server with the following URL:then this gets parsed as a
fetchReleaseMetadataroute rather than adownloadSourceArchiveroute.I believe the bug is here in
VaporTransport.swift:Currently the OpenAPI path
/{scope}/{name}/{version}.zipis getting parsed as:I would assume that the OpenAPI path
/{scope}/{name}/{version}.zipshould get parsed as:Is this a correct assumption?
If so, then I will put up a PR which accomplishes this.