Skip to content

Commit 11985e3

Browse files
committed
feat(model-server): add known specific operationIds
1 parent e1959f1 commit 11985e3

File tree

3 files changed

+20
-10
lines changed

3 files changed

+20
-10
lines changed

api/model-server.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,21 @@ paths:
2424
/v2/server-id:
2525
get:
2626
description: ""
27+
operationId: getServerId
2728
responses:
2829
"200":
2930
$ref: '#/components/responses/200'
3031
/v2/user-id:
3132
get:
3233
description: ""
34+
operationId: getUserId
3335
responses:
3436
"200":
3537
$ref: '#/components/responses/200'
3638
/v2/generate-client-id:
3739
post:
3840
description: ""
41+
operationId: postGenerateClientId
3942
responses:
4043
"200":
4144
$ref: '#/components/responses/200'
@@ -66,12 +69,14 @@ paths:
6669
/v2/repositories:
6770
get:
6871
description: ""
72+
operationId: getRepositories
6973
responses:
7074
"200":
7175
$ref: '#/components/responses/200'
7276
/v2/repositories/{repository}/branches:
7377
get:
7478
description: ""
79+
operationId: getRepositoryBranches
7580
parameters:
7681
- name: repository
7782
in: "path"
@@ -84,6 +89,7 @@ paths:
8489
/v2/repositories/{repository}/branches/{branch}:
8590
get:
8691
description: ""
92+
operationId: getRepositoryBranch
8793
parameters:
8894
- name: lastKnown
8995
in: "query"
@@ -142,6 +148,7 @@ paths:
142148
/v2/repositories/{repository}/branches/{branch}/hash:
143149
get:
144150
description: ""
151+
operationId: getRepositoryBranchHash
145152
parameters:
146153
- name: repository
147154
in: "path"
@@ -299,6 +306,7 @@ paths:
299306
/v2/repositories/{repository}/init:
300307
post:
301308
description: ""
309+
operationId: initializeRepository
302310
parameters:
303311
- name: useRoleIds
304312
in: "query"
@@ -326,6 +334,7 @@ paths:
326334
/v2/repositories/{repository}/versions/{versionHash}:
327335
get:
328336
description: ""
337+
operationId: getRepositoryVersionHash
329338
parameters:
330339
- name: lastKnown
331340
in: "query"

model-server/src/main/kotlin/org/modelix/model/server/Main.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ object Main {
162162
installAuthentication(unitTestMode = !KeycloakUtils.isEnabled())
163163
install(ForwardedHeaders)
164164
install(Resources)
165+
// https://opensource.zalando.com/restful-api-guidelines/#136
165166
install(IgnoreTrailingSlash)
166167
install(WebSockets) {
167168
pingPeriod = Duration.ofSeconds(30)

model-server/src/main/kotlin/org/modelix/model/server/handlers/ModelReplicationServer.kt

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,30 +76,30 @@ class ModelReplicationServer(val repositoriesManager: RepositoriesManager) {
7676
}
7777

7878
private fun Route.installHandlers() {
79-
post<Paths.v2GenerateClientIdPost> {
79+
post<Paths.postGenerateClientId> {
8080
call.respondText(storeClient.generateId("clientId").toString())
8181
}
82-
get<Paths.v2ServerIdGet> {
82+
get<Paths.getServerId> {
8383
call.respondText(repositoriesManager.getServerId())
8484
}
85-
get<Paths.v2ServerIdGet> {
85+
get<Paths.getServerId> {
8686
call.respondText(repositoriesManager.getServerId())
8787
}
88-
get<Paths.v2UserIdGet> {
88+
get<Paths.getUserId> {
8989
call.respondText(call.getUserName() ?: call.request.origin.remoteHost)
9090
}
91-
get<Paths.v2RepositoriesGet> {
91+
get<Paths.getRepositories> {
9292
call.respondText(repositoriesManager.getRepositories().joinToString("\n") { it.id })
9393
}
9494

95-
get<Paths.v2RepositoriesRepositoryBranchesGet> {
95+
get<Paths.getRepositoryBranches> {
9696
fun ApplicationCall.repositoryId() = RepositoryId(parameters["repository"]!!)
9797
fun PipelineContext<Unit, ApplicationCall>.repositoryId() = call.repositoryId()
9898

9999
call.respondText(repositoriesManager.getBranchNames(repositoryId()).joinToString("\n"))
100100
}
101101

102-
get<Paths.v2RepositoriesRepositoryBranchesBranchGet> {
102+
get<Paths.getRepositoryBranch> {
103103
fun ApplicationCall.repositoryId() = RepositoryId(parameters["repository"]!!)
104104
fun PipelineContext<Unit, ApplicationCall>.repositoryId() = call.repositoryId()
105105

@@ -119,7 +119,7 @@ class ModelReplicationServer(val repositoriesManager: RepositoriesManager) {
119119
call.respondDelta(versionHash, baseVersionHash)
120120
}
121121

122-
get<Paths.v2RepositoriesRepositoryBranchesBranchHashGet> {
122+
get<Paths.getRepositoryBranchHash> {
123123
fun ApplicationCall.repositoryId() = RepositoryId(parameters["repository"]!!)
124124
fun PipelineContext<Unit, ApplicationCall>.repositoryId() = call.repositoryId()
125125

@@ -138,7 +138,7 @@ class ModelReplicationServer(val repositoriesManager: RepositoriesManager) {
138138
call.respondText(versionHash)
139139
}
140140

141-
post<Paths.v2RepositoriesRepositoryInitPost> {
141+
post<Paths.initializeRepository> {
142142
fun ApplicationCall.repositoryId() = RepositoryId(parameters["repository"]!!)
143143
fun PipelineContext<Unit, ApplicationCall>.repositoryId() = call.repositoryId()
144144

@@ -208,7 +208,7 @@ class ModelReplicationServer(val repositoriesManager: RepositoriesManager) {
208208
}
209209
}
210210

211-
get<Paths.v2RepositoriesRepositoryVersionsVersionHashGet> {
211+
get<Paths.getRepositoryVersionHash> {
212212
fun ApplicationCall.repositoryId() = RepositoryId(parameters["repository"]!!)
213213
fun PipelineContext<Unit, ApplicationCall>.repositoryId() = call.repositoryId()
214214

0 commit comments

Comments
 (0)