1
- /* *
2
- * OpenAPI Petstore
3
- * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
4
- *
5
- * The version of the OpenAPI document: 1.0.0
6
- *
7
- *
8
- * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
- * https://openapi-generator.tech
10
- * Do not edit the class manually.
11
- */
12
- package org.openapitools.server.apis
13
-
14
- import com.google.gson.Gson
15
- import io.ktor.application.call
16
- import io.ktor.auth.UserIdPrincipal
17
- import io.ktor.auth.authentication
18
- import io.ktor.auth.authenticate
19
- import io.ktor.auth.OAuthAccessTokenResponse
20
- import io.ktor.auth.OAuthServerSettings
21
- import io.ktor.http.ContentType
22
- import io.ktor.http.HttpStatusCode
23
- import io.ktor.locations.KtorExperimentalLocationsAPI
24
- import io.ktor.locations.delete
25
- import io.ktor.locations.get
26
- import io.ktor.response.respond
27
- import io.ktor.response.respondText
28
- import io.ktor.routing.Route
29
- import io.ktor.routing.post
30
- import io.ktor.routing.put
31
- import io.ktor.routing.route
32
-
33
- import org.openapitools.server.Paths
34
- import org.openapitools.server.infrastructure.ApiPrincipal
35
-
36
-
37
- import org.openapitools.server.models.ApiResponse
38
- import org.openapitools.server.models.Pet
39
-
40
- @KtorExperimentalLocationsAPI
41
- fun Route.PetApi () {
42
- val gson = Gson ()
43
- val empty = mutableMapOf<String , Any ?>()
44
-
45
- route(" /pet" ) {
46
- authenticate(" petstore_auth" ) {
47
- post {
48
- val principal = call.authentication.principal<OAuthAccessTokenResponse >()
49
-
50
- if (principal == null ) {
51
- call.respond(HttpStatusCode .Unauthorized )
52
- } else {
53
- call.respond(HttpStatusCode .NotImplemented )
54
- }
55
- }
56
- }
57
- }
58
-
59
-
60
- delete<Paths .deletePet> { _: Paths .deletePet ->
61
- val principal = call.authentication.principal<OAuthAccessTokenResponse >()
62
-
63
- if (principal == null ) {
64
- call.respond(HttpStatusCode .Unauthorized )
65
- } else {
66
- call.respond(HttpStatusCode .NotImplemented )
67
- }
68
- }
69
-
70
-
71
- get<Paths .findPetsByStatus> { _: Paths .findPetsByStatus ->
72
- val principal = call.authentication.principal<OAuthAccessTokenResponse >()
73
-
74
- if (principal == null ) {
75
- call.respond(HttpStatusCode .Unauthorized )
76
- } else {
77
- val exampleContentType = " application/json"
1
+ /* *
2
+ * OpenAPI Petstore
3
+ * This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
4
+ *
5
+ * The version of the OpenAPI document: 1.0.0
6
+ *
7
+ *
8
+ * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
9
+ * https://openapi-generator.tech
10
+ * Do not edit the class manually.
11
+ */
12
+ package org.openapitools.server.apis
13
+
14
+ import com.google.gson.Gson
15
+ import io.ktor.application.call
16
+ import io.ktor.auth.UserIdPrincipal
17
+ import io.ktor.auth.authentication
18
+ import io.ktor.auth.authenticate
19
+ import io.ktor.auth.OAuthAccessTokenResponse
20
+ import io.ktor.auth.OAuthServerSettings
21
+ import io.ktor.http.ContentType
22
+ import io.ktor.http.HttpStatusCode
23
+ import io.ktor.locations.KtorExperimentalLocationsAPI
24
+ import io.ktor.locations.delete
25
+ import io.ktor.locations.get
26
+ import io.ktor.response.respond
27
+ import io.ktor.response.respondText
28
+ import io.ktor.routing.Route
29
+ import io.ktor.routing.post
30
+ import io.ktor.routing.put
31
+ import io.ktor.routing.route
32
+
33
+ import org.openapitools.server.Paths
34
+ import org.openapitools.server.infrastructure.ApiPrincipal
35
+
36
+
37
+ import org.openapitools.server.models.ApiResponse
38
+ import org.openapitools.server.models.Pet
39
+
40
+ @KtorExperimentalLocationsAPI
41
+ fun Route.PetApi () {
42
+ val gson = Gson ()
43
+ val empty = mutableMapOf<String , Any ?>()
44
+
45
+ route(" /pet" ) {
46
+ authenticate(" petstore_auth" ) {
47
+ post {
48
+ val principal = call.authentication.principal<OAuthAccessTokenResponse >()
49
+
50
+ if (principal == null ) {
51
+ call.respond(HttpStatusCode .Unauthorized )
52
+ } else {
53
+ call.respond(HttpStatusCode .NotImplemented )
54
+ }
55
+ }
56
+ }
57
+ }
58
+
59
+
60
+ delete<Paths .deletePet> { _: Paths .deletePet ->
61
+ val principal = call.authentication.principal<OAuthAccessTokenResponse >()
62
+
63
+ if (principal == null ) {
64
+ call.respond(HttpStatusCode .Unauthorized )
65
+ } else {
66
+ call.respond(HttpStatusCode .NotImplemented )
67
+ }
68
+ }
69
+
70
+
71
+ get<Paths .findPetsByStatus> { _: Paths .findPetsByStatus ->
72
+ val principal = call.authentication.principal<OAuthAccessTokenResponse >()
73
+
74
+ if (principal == null ) {
75
+ call.respond(HttpStatusCode .Unauthorized )
76
+ } else {
77
+ val exampleContentType = " application/json"
78
78
val exampleContentString = """ {
79
79
"photoUrls" : [ "photoUrls", "photoUrls" ],
80
80
"name" : "doggie",
@@ -91,24 +91,24 @@ fun Route.PetApi() {
91
91
"id" : 1
92
92
} ],
93
93
"status" : "available"
94
- }"""
95
-
96
- when (exampleContentType) {
97
- " application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class .java))
98
- " application/xml" -> call.respondText(exampleContentString, ContentType .Text .Xml )
99
- else -> call.respondText(exampleContentString)
100
- }
101
- }
102
- }
103
-
104
-
105
- get<Paths .findPetsByTags> { _: Paths .findPetsByTags ->
106
- val principal = call.authentication.principal<OAuthAccessTokenResponse >()
107
-
108
- if (principal == null ) {
109
- call.respond(HttpStatusCode .Unauthorized )
110
- } else {
111
- val exampleContentType = " application/json"
94
+ }"""
95
+
96
+ when (exampleContentType) {
97
+ " application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class .java))
98
+ " application/xml" -> call.respondText(exampleContentString, ContentType .Text .Xml )
99
+ else -> call.respondText(exampleContentString)
100
+ }
101
+ }
102
+ }
103
+
104
+
105
+ get<Paths .findPetsByTags> { _: Paths .findPetsByTags ->
106
+ val principal = call.authentication.principal<OAuthAccessTokenResponse >()
107
+
108
+ if (principal == null ) {
109
+ call.respond(HttpStatusCode .Unauthorized )
110
+ } else {
111
+ val exampleContentType = " application/json"
112
112
val exampleContentString = """ {
113
113
"photoUrls" : [ "photoUrls", "photoUrls" ],
114
114
"name" : "doggie",
@@ -125,24 +125,24 @@ fun Route.PetApi() {
125
125
"id" : 1
126
126
} ],
127
127
"status" : "available"
128
- }"""
129
-
130
- when (exampleContentType) {
131
- " application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class .java))
132
- " application/xml" -> call.respondText(exampleContentString, ContentType .Text .Xml )
133
- else -> call.respondText(exampleContentString)
134
- }
135
- }
136
- }
137
-
138
-
139
- get<Paths .getPetById> { _: Paths .getPetById ->
140
- val principal = call.authentication.principal<ApiPrincipal >()
141
-
142
- if (principal == null ) {
143
- call.respond(HttpStatusCode .Unauthorized )
144
- } else {
145
- val exampleContentType = " application/json"
128
+ }"""
129
+
130
+ when (exampleContentType) {
131
+ " application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class .java))
132
+ " application/xml" -> call.respondText(exampleContentString, ContentType .Text .Xml )
133
+ else -> call.respondText(exampleContentString)
134
+ }
135
+ }
136
+ }
137
+
138
+
139
+ get<Paths .getPetById> { _: Paths .getPetById ->
140
+ val principal = call.authentication.principal<ApiPrincipal >()
141
+
142
+ if (principal == null ) {
143
+ call.respond(HttpStatusCode .Unauthorized )
144
+ } else {
145
+ val exampleContentType = " application/json"
146
146
val exampleContentString = """ {
147
147
"photoUrls" : [ "photoUrls", "photoUrls" ],
148
148
"name" : "doggie",
@@ -159,70 +159,70 @@ fun Route.PetApi() {
159
159
"id" : 1
160
160
} ],
161
161
"status" : "available"
162
- }"""
163
-
164
- when (exampleContentType) {
165
- " application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class .java))
166
- " application/xml" -> call.respondText(exampleContentString, ContentType .Text .Xml )
167
- else -> call.respondText(exampleContentString)
168
- }
169
- }
170
- }
171
-
172
-
173
- route(" /pet" ) {
174
- authenticate(" petstore_auth" ) {
175
- put {
176
- val principal = call.authentication.principal<OAuthAccessTokenResponse >()
177
-
178
- if (principal == null ) {
179
- call.respond(HttpStatusCode .Unauthorized )
180
- } else {
181
- call.respond(HttpStatusCode .NotImplemented )
182
- }
183
- }
184
- }
185
- }
186
-
187
-
188
- route(" /pet/{petId}" ) {
189
- authenticate(" petstore_auth" ) {
190
- post {
191
- val principal = call.authentication.principal<OAuthAccessTokenResponse >()
192
-
193
- if (principal == null ) {
194
- call.respond(HttpStatusCode .Unauthorized )
195
- } else {
196
- call.respond(HttpStatusCode .NotImplemented )
197
- }
198
- }
199
- }
200
- }
201
-
202
-
203
- route(" /pet/{petId}/uploadImage" ) {
204
- authenticate(" petstore_auth" ) {
205
- post {
206
- val principal = call.authentication.principal<OAuthAccessTokenResponse >()
207
-
208
- if (principal == null ) {
209
- call.respond(HttpStatusCode .Unauthorized )
210
- } else {
211
- val exampleContentType = " application/json"
162
+ }"""
163
+
164
+ when (exampleContentType) {
165
+ " application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class .java))
166
+ " application/xml" -> call.respondText(exampleContentString, ContentType .Text .Xml )
167
+ else -> call.respondText(exampleContentString)
168
+ }
169
+ }
170
+ }
171
+
172
+
173
+ route(" /pet" ) {
174
+ authenticate(" petstore_auth" ) {
175
+ put {
176
+ val principal = call.authentication.principal<OAuthAccessTokenResponse >()
177
+
178
+ if (principal == null ) {
179
+ call.respond(HttpStatusCode .Unauthorized )
180
+ } else {
181
+ call.respond(HttpStatusCode .NotImplemented )
182
+ }
183
+ }
184
+ }
185
+ }
186
+
187
+
188
+ route(" /pet/{petId}" ) {
189
+ authenticate(" petstore_auth" ) {
190
+ post {
191
+ val principal = call.authentication.principal<OAuthAccessTokenResponse >()
192
+
193
+ if (principal == null ) {
194
+ call.respond(HttpStatusCode .Unauthorized )
195
+ } else {
196
+ call.respond(HttpStatusCode .NotImplemented )
197
+ }
198
+ }
199
+ }
200
+ }
201
+
202
+
203
+ route(" /pet/{petId}/uploadImage" ) {
204
+ authenticate(" petstore_auth" ) {
205
+ post {
206
+ val principal = call.authentication.principal<OAuthAccessTokenResponse >()
207
+
208
+ if (principal == null ) {
209
+ call.respond(HttpStatusCode .Unauthorized )
210
+ } else {
211
+ val exampleContentType = " application/json"
212
212
val exampleContentString = """ {
213
213
"code" : 0,
214
214
"type" : "type",
215
215
"message" : "message"
216
- }"""
217
-
218
- when (exampleContentType) {
219
- " application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class .java))
220
- " application/xml" -> call.respondText(exampleContentString, ContentType .Text .Xml )
221
- else -> call.respondText(exampleContentString)
222
- }
223
- }
224
- }
225
- }
226
- }
227
-
228
- }
216
+ }"""
217
+
218
+ when (exampleContentType) {
219
+ " application/json" -> call.respond(gson.fromJson(exampleContentString, empty::class .java))
220
+ " application/xml" -> call.respondText(exampleContentString, ContentType .Text .Xml )
221
+ else -> call.respondText(exampleContentString)
222
+ }
223
+ }
224
+ }
225
+ }
226
+ }
227
+
228
+ }
0 commit comments