Skip to content

Commit 919945b

Browse files
authored
ensure haskell, erlang server samles up-to-date (#9851)
1 parent 1cd1001 commit 919945b

File tree

8 files changed

+44
-73
lines changed

8 files changed

+44
-73
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,7 @@ cabal.project.local
212212
samples/client/petstore/haskell-http-client/docs/haddock-bundle.min.js
213213
samples/client/petstore/haskell-http-client/docs/meta.json
214214
samples/client/petstore/haskell-http-client/docs/quick-jump.css
215+
samples/server/petstore/haskell-servant/stack.yaml.lock
215216

216217
# R
217218
.Rproj.user
File renamed without changes.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
5.1.1-SNAPSHOT
1+
5.2.0-SNAPSHOT

samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts

Lines changed: 9 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,7 @@ export class PetApi extends runtime.BaseAPI {
9898

9999
if (this.configuration && this.configuration.accessToken) {
100100
// oauth required
101-
if (typeof this.configuration.accessToken === 'function') {
102-
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
103-
} else {
104-
headerParameters["Authorization"] = this.configuration.accessToken;
105-
}
101+
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
106102
}
107103

108104
const response = await this.request({
@@ -141,11 +137,7 @@ export class PetApi extends runtime.BaseAPI {
141137

142138
if (this.configuration && this.configuration.accessToken) {
143139
// oauth required
144-
if (typeof this.configuration.accessToken === 'function') {
145-
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
146-
} else {
147-
headerParameters["Authorization"] = this.configuration.accessToken;
148-
}
140+
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
149141
}
150142

151143
const response = await this.request({
@@ -184,11 +176,7 @@ export class PetApi extends runtime.BaseAPI {
184176

185177
if (this.configuration && this.configuration.accessToken) {
186178
// oauth required
187-
if (typeof this.configuration.accessToken === 'function') {
188-
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
189-
} else {
190-
headerParameters["Authorization"] = this.configuration.accessToken;
191-
}
179+
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
192180
}
193181

194182
const response = await this.request({
@@ -229,11 +217,7 @@ export class PetApi extends runtime.BaseAPI {
229217

230218
if (this.configuration && this.configuration.accessToken) {
231219
// oauth required
232-
if (typeof this.configuration.accessToken === 'function') {
233-
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
234-
} else {
235-
headerParameters["Authorization"] = this.configuration.accessToken;
236-
}
220+
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
237221
}
238222

239223
const response = await this.request({
@@ -274,11 +258,7 @@ export class PetApi extends runtime.BaseAPI {
274258

275259
if (this.configuration && this.configuration.accessToken) {
276260
// oauth required
277-
if (typeof this.configuration.accessToken === 'function') {
278-
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
279-
} else {
280-
headerParameters["Authorization"] = this.configuration.accessToken;
281-
}
261+
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
282262
}
283263

284264
const response = await this.request({
@@ -319,11 +299,7 @@ export class PetApi extends runtime.BaseAPI {
319299

320300
if (this.configuration && this.configuration.accessToken) {
321301
// oauth required
322-
if (typeof this.configuration.accessToken === 'function') {
323-
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
324-
} else {
325-
headerParameters["Authorization"] = this.configuration.accessToken;
326-
}
302+
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
327303
}
328304

329305
const response = await this.request({
@@ -397,11 +373,7 @@ export class PetApi extends runtime.BaseAPI {
397373

398374
if (this.configuration && this.configuration.accessToken) {
399375
// oauth required
400-
if (typeof this.configuration.accessToken === 'function') {
401-
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
402-
} else {
403-
headerParameters["Authorization"] = this.configuration.accessToken;
404-
}
376+
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
405377
}
406378

407379
const response = await this.request({
@@ -436,11 +408,7 @@ export class PetApi extends runtime.BaseAPI {
436408

437409
if (this.configuration && this.configuration.accessToken) {
438410
// oauth required
439-
if (typeof this.configuration.accessToken === 'function') {
440-
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
441-
} else {
442-
headerParameters["Authorization"] = this.configuration.accessToken;
443-
}
411+
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
444412
}
445413

446414
const consumes: runtime.Consume[] = [
@@ -497,11 +465,7 @@ export class PetApi extends runtime.BaseAPI {
497465

498466
if (this.configuration && this.configuration.accessToken) {
499467
// oauth required
500-
if (typeof this.configuration.accessToken === 'function') {
501-
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
502-
} else {
503-
headerParameters["Authorization"] = this.configuration.accessToken;
504-
}
468+
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
505469
}
506470

507471
const consumes: runtime.Consume[] = [

samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ export class BaseAPI {
9090
if (middleware.post) {
9191
response = await middleware.post({
9292
fetch: this.fetchApi,
93-
url,
94-
init,
93+
url: fetchParams.url,
94+
init: fetchParams.init,
9595
response: response.clone(),
9696
}) || response;
9797
}
@@ -135,7 +135,7 @@ export interface ConfigurationParameters {
135135
username?: string; // parameter for basic security
136136
password?: string; // parameter for basic security
137137
apiKey?: string | ((name: string) => string); // parameter for apiKey security
138-
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security
138+
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
139139
headers?: HTTPHeaders; //header params we want to use on every request
140140
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
141141
}
@@ -175,10 +175,10 @@ export class Configuration {
175175
return undefined;
176176
}
177177

178-
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
178+
get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
179179
const accessToken = this.configuration.accessToken;
180180
if (accessToken) {
181-
return typeof accessToken === 'function' ? accessToken : () => accessToken;
181+
return typeof accessToken === 'function' ? accessToken : async () => accessToken;
182182
}
183183
return undefined;
184184
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
README.md
2+
Setup.hs
3+
lib/OpenAPIPetstore/API.hs
4+
lib/OpenAPIPetstore/Types.hs
5+
openapi-petstore.cabal
6+
stack.yaml

samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -137,26 +137,26 @@ formatSeparatedQueryList char = T.intercalate (T.singleton char) . map toQueryPa
137137

138138
-- | Servant type-level API, generated from the OpenAPI spec for OpenAPIPetstore.
139139
type OpenAPIPetstoreAPI
140-
= "pet" :> ReqBody '[JSON] Pet :> Verb 'POST 200 '[JSON] () -- 'addPet' route
141-
:<|> "pet" :> Capture "petId" Integer :> Header "api_key" Text :> Verb 'DELETE 200 '[JSON] () -- 'deletePet' route
140+
= "pet" :> ReqBody '[JSON] Pet :> Verb 'POST 200 '[JSON] NoContent -- 'addPet' route
141+
:<|> "pet" :> Capture "petId" Integer :> Header "api_key" Text :> Verb 'DELETE 200 '[JSON] NoContent -- 'deletePet' route
142142
:<|> "pet" :> "findByStatus" :> QueryParam "status" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[JSON] [Pet] -- 'findPetsByStatus' route
143143
:<|> "pet" :> "findByTags" :> QueryParam "tags" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[JSON] [Pet] -- 'findPetsByTags' route
144144
:<|> "pet" :> Capture "petId" Integer :> Verb 'GET 200 '[JSON] Pet -- 'getPetById' route
145-
:<|> "pet" :> ReqBody '[JSON] Pet :> Verb 'PUT 200 '[JSON] () -- 'updatePet' route
146-
:<|> "pet" :> Capture "petId" Integer :> ReqBody '[FormUrlEncoded] FormUpdatePetWithForm :> Verb 'POST 200 '[JSON] () -- 'updatePetWithForm' route
145+
:<|> "pet" :> ReqBody '[JSON] Pet :> Verb 'PUT 200 '[JSON] NoContent -- 'updatePet' route
146+
:<|> "pet" :> Capture "petId" Integer :> ReqBody '[FormUrlEncoded] FormUpdatePetWithForm :> Verb 'POST 200 '[JSON] NoContent -- 'updatePetWithForm' route
147147
:<|> "pet" :> Capture "petId" Integer :> "uploadImage" :> ReqBody '[FormUrlEncoded] FormUploadFile :> Verb 'POST 200 '[JSON] ApiResponse -- 'uploadFile' route
148-
:<|> "store" :> "order" :> Capture "orderId" Text :> Verb 'DELETE 200 '[JSON] () -- 'deleteOrder' route
148+
:<|> "store" :> "order" :> Capture "orderId" Text :> Verb 'DELETE 200 '[JSON] NoContent -- 'deleteOrder' route
149149
:<|> "store" :> "inventory" :> Verb 'GET 200 '[JSON] ((Map.Map String Int)) -- 'getInventory' route
150150
:<|> "store" :> "order" :> Capture "orderId" Integer :> Verb 'GET 200 '[JSON] Order -- 'getOrderById' route
151151
:<|> "store" :> "order" :> ReqBody '[JSON] Order :> Verb 'POST 200 '[JSON] Order -- 'placeOrder' route
152-
:<|> "user" :> ReqBody '[JSON] User :> Verb 'POST 200 '[JSON] () -- 'createUser' route
153-
:<|> "user" :> "createWithArray" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] () -- 'createUsersWithArrayInput' route
154-
:<|> "user" :> "createWithList" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] () -- 'createUsersWithListInput' route
155-
:<|> "user" :> Capture "username" Text :> Verb 'DELETE 200 '[JSON] () -- 'deleteUser' route
152+
:<|> "user" :> ReqBody '[JSON] User :> Verb 'POST 200 '[JSON] NoContent -- 'createUser' route
153+
:<|> "user" :> "createWithArray" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] NoContent -- 'createUsersWithArrayInput' route
154+
:<|> "user" :> "createWithList" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] NoContent -- 'createUsersWithListInput' route
155+
:<|> "user" :> Capture "username" Text :> Verb 'DELETE 200 '[JSON] NoContent -- 'deleteUser' route
156156
:<|> "user" :> Capture "username" Text :> Verb 'GET 200 '[JSON] User -- 'getUserByName' route
157157
:<|> "user" :> "login" :> QueryParam "username" Text :> QueryParam "password" Text :> Verb 'GET 200 '[JSON] Text -- 'loginUser' route
158-
:<|> "user" :> "logout" :> Verb 'GET 200 '[JSON] () -- 'logoutUser' route
159-
:<|> "user" :> Capture "username" Text :> ReqBody '[JSON] User :> Verb 'PUT 200 '[JSON] () -- 'updateUser' route
158+
:<|> "user" :> "logout" :> Verb 'GET 200 '[JSON] NoContent -- 'logoutUser' route
159+
:<|> "user" :> Capture "username" Text :> ReqBody '[JSON] User :> Verb 'PUT 200 '[JSON] NoContent -- 'updateUser' route
160160
:<|> Raw
161161

162162

@@ -177,26 +177,26 @@ newtype OpenAPIPetstoreClientError = OpenAPIPetstoreClientError ClientError
177177
-- is a backend that executes actions by sending HTTP requests (see @createOpenAPIPetstoreClient@). Alternatively, provided
178178
-- a backend, the API can be served using @runOpenAPIPetstoreMiddlewareServer@.
179179
data OpenAPIPetstoreBackend m = OpenAPIPetstoreBackend
180-
{ addPet :: Pet -> m (){- ^ -}
181-
, deletePet :: Integer -> Maybe Text -> m (){- ^ -}
180+
{ addPet :: Pet -> m NoContent{- ^ -}
181+
, deletePet :: Integer -> Maybe Text -> m NoContent{- ^ -}
182182
, findPetsByStatus :: Maybe [Text] -> m [Pet]{- ^ Multiple status values can be provided with comma separated strings -}
183183
, findPetsByTags :: Maybe [Text] -> m [Pet]{- ^ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. -}
184184
, getPetById :: Integer -> m Pet{- ^ Returns a single pet -}
185-
, updatePet :: Pet -> m (){- ^ -}
186-
, updatePetWithForm :: Integer -> FormUpdatePetWithForm -> m (){- ^ -}
185+
, updatePet :: Pet -> m NoContent{- ^ -}
186+
, updatePetWithForm :: Integer -> FormUpdatePetWithForm -> m NoContent{- ^ -}
187187
, uploadFile :: Integer -> FormUploadFile -> m ApiResponse{- ^ -}
188-
, deleteOrder :: Text -> m (){- ^ For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors -}
188+
, deleteOrder :: Text -> m NoContent{- ^ For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors -}
189189
, getInventory :: m ((Map.Map String Int)){- ^ Returns a map of status codes to quantities -}
190190
, getOrderById :: Integer -> m Order{- ^ For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions -}
191191
, placeOrder :: Order -> m Order{- ^ -}
192-
, createUser :: User -> m (){- ^ This can only be done by the logged in user. -}
193-
, createUsersWithArrayInput :: [User] -> m (){- ^ -}
194-
, createUsersWithListInput :: [User] -> m (){- ^ -}
195-
, deleteUser :: Text -> m (){- ^ This can only be done by the logged in user. -}
192+
, createUser :: User -> m NoContent{- ^ This can only be done by the logged in user. -}
193+
, createUsersWithArrayInput :: [User] -> m NoContent{- ^ -}
194+
, createUsersWithListInput :: [User] -> m NoContent{- ^ -}
195+
, deleteUser :: Text -> m NoContent{- ^ This can only be done by the logged in user. -}
196196
, getUserByName :: Text -> m User{- ^ -}
197197
, loginUser :: Maybe Text -> Maybe Text -> m Text{- ^ -}
198-
, logoutUser :: m (){- ^ -}
199-
, updateUser :: Text -> User -> m (){- ^ This can only be done by the logged in user. -}
198+
, logoutUser :: m NoContent{- ^ -}
199+
, updateUser :: Text -> User -> m NoContent{- ^ This can only be done by the logged in user. -}
200200
}
201201

202202
newtype OpenAPIPetstoreClient a = OpenAPIPetstoreClient

0 commit comments

Comments
 (0)