diff --git a/.gitignore b/.gitignore index 3a964a0bc5e..9ce6c04e156 100644 --- a/.gitignore +++ b/.gitignore @@ -212,6 +212,7 @@ cabal.project.local samples/client/petstore/haskell-http-client/docs/haddock-bundle.min.js samples/client/petstore/haskell-http-client/docs/meta.json samples/client/petstore/haskell-http-client/docs/quick-jump.css +samples/server/petstore/haskell-servant/stack.yaml.lock # R .Rproj.user diff --git a/bin/configs/other/erlang-server.yaml b/bin/configs/erlang-server.yaml similarity index 100% rename from bin/configs/other/erlang-server.yaml rename to bin/configs/erlang-server.yaml diff --git a/bin/configs/other/haskell-servant.yaml b/bin/configs/haskell-servant.yaml similarity index 100% rename from bin/configs/other/haskell-servant.yaml rename to bin/configs/haskell-servant.yaml diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/.openapi-generator/VERSION b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/.openapi-generator/VERSION index d509cc92aa8..6555596f931 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/.openapi-generator/VERSION +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/.openapi-generator/VERSION @@ -1 +1 @@ -5.1.1-SNAPSHOT \ No newline at end of file +5.2.0-SNAPSHOT \ No newline at end of file diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts index 7726dae7530..5c881e816cd 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/apis/PetApi.ts @@ -98,11 +98,7 @@ export class PetApi extends runtime.BaseAPI { if (this.configuration && this.configuration.accessToken) { // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } const response = await this.request({ @@ -141,11 +137,7 @@ export class PetApi extends runtime.BaseAPI { if (this.configuration && this.configuration.accessToken) { // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } const response = await this.request({ @@ -184,11 +176,7 @@ export class PetApi extends runtime.BaseAPI { if (this.configuration && this.configuration.accessToken) { // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } const response = await this.request({ @@ -229,11 +217,7 @@ export class PetApi extends runtime.BaseAPI { if (this.configuration && this.configuration.accessToken) { // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } const response = await this.request({ @@ -274,11 +258,7 @@ export class PetApi extends runtime.BaseAPI { if (this.configuration && this.configuration.accessToken) { // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } const response = await this.request({ @@ -319,11 +299,7 @@ export class PetApi extends runtime.BaseAPI { if (this.configuration && this.configuration.accessToken) { // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } const response = await this.request({ @@ -397,11 +373,7 @@ export class PetApi extends runtime.BaseAPI { if (this.configuration && this.configuration.accessToken) { // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } const response = await this.request({ @@ -436,11 +408,7 @@ export class PetApi extends runtime.BaseAPI { if (this.configuration && this.configuration.accessToken) { // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } const consumes: runtime.Consume[] = [ @@ -497,11 +465,7 @@ export class PetApi extends runtime.BaseAPI { if (this.configuration && this.configuration.accessToken) { // oauth required - if (typeof this.configuration.accessToken === 'function') { - headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); - } else { - headerParameters["Authorization"] = this.configuration.accessToken; - } + headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]); } const consumes: runtime.Consume[] = [ diff --git a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts index da5d9059bad..40ac35e9d19 100644 --- a/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts +++ b/samples/client/petstore/typescript-fetch/builds/sagas-and-records/src/runtime.ts @@ -90,8 +90,8 @@ export class BaseAPI { if (middleware.post) { response = await middleware.post({ fetch: this.fetchApi, - url, - init, + url: fetchParams.url, + init: fetchParams.init, response: response.clone(), }) || response; } @@ -135,7 +135,7 @@ export interface ConfigurationParameters { username?: string; // parameter for basic security password?: string; // parameter for basic security apiKey?: string | ((name: string) => string); // parameter for apiKey security - accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security + accessToken?: string | Promise | ((name?: string, scopes?: string[]) => string | Promise); // parameter for oauth2 security headers?: HTTPHeaders; //header params we want to use on every request credentials?: RequestCredentials; //value for the credentials param we want to use on each request } @@ -175,10 +175,10 @@ export class Configuration { return undefined; } - get accessToken(): ((name: string, scopes?: string[]) => string) | undefined { + get accessToken(): ((name?: string, scopes?: string[]) => string | Promise) | undefined { const accessToken = this.configuration.accessToken; if (accessToken) { - return typeof accessToken === 'function' ? accessToken : () => accessToken; + return typeof accessToken === 'function' ? accessToken : async () => accessToken; } return undefined; } diff --git a/samples/server/petstore/haskell-servant/.openapi-generator/FILES b/samples/server/petstore/haskell-servant/.openapi-generator/FILES new file mode 100644 index 00000000000..405513c6811 --- /dev/null +++ b/samples/server/petstore/haskell-servant/.openapi-generator/FILES @@ -0,0 +1,6 @@ +README.md +Setup.hs +lib/OpenAPIPetstore/API.hs +lib/OpenAPIPetstore/Types.hs +openapi-petstore.cabal +stack.yaml diff --git a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs index 3d94427f99d..751713adc78 100644 --- a/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs +++ b/samples/server/petstore/haskell-servant/lib/OpenAPIPetstore/API.hs @@ -137,26 +137,26 @@ formatSeparatedQueryList char = T.intercalate (T.singleton char) . map toQueryPa -- | Servant type-level API, generated from the OpenAPI spec for OpenAPIPetstore. type OpenAPIPetstoreAPI - = "pet" :> ReqBody '[JSON] Pet :> Verb 'POST 200 '[JSON] () -- 'addPet' route - :<|> "pet" :> Capture "petId" Integer :> Header "api_key" Text :> Verb 'DELETE 200 '[JSON] () -- 'deletePet' route + = "pet" :> ReqBody '[JSON] Pet :> Verb 'POST 200 '[JSON] NoContent -- 'addPet' route + :<|> "pet" :> Capture "petId" Integer :> Header "api_key" Text :> Verb 'DELETE 200 '[JSON] NoContent -- 'deletePet' route :<|> "pet" :> "findByStatus" :> QueryParam "status" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[JSON] [Pet] -- 'findPetsByStatus' route :<|> "pet" :> "findByTags" :> QueryParam "tags" (QueryList 'CommaSeparated (Text)) :> Verb 'GET 200 '[JSON] [Pet] -- 'findPetsByTags' route :<|> "pet" :> Capture "petId" Integer :> Verb 'GET 200 '[JSON] Pet -- 'getPetById' route - :<|> "pet" :> ReqBody '[JSON] Pet :> Verb 'PUT 200 '[JSON] () -- 'updatePet' route - :<|> "pet" :> Capture "petId" Integer :> ReqBody '[FormUrlEncoded] FormUpdatePetWithForm :> Verb 'POST 200 '[JSON] () -- 'updatePetWithForm' route + :<|> "pet" :> ReqBody '[JSON] Pet :> Verb 'PUT 200 '[JSON] NoContent -- 'updatePet' route + :<|> "pet" :> Capture "petId" Integer :> ReqBody '[FormUrlEncoded] FormUpdatePetWithForm :> Verb 'POST 200 '[JSON] NoContent -- 'updatePetWithForm' route :<|> "pet" :> Capture "petId" Integer :> "uploadImage" :> ReqBody '[FormUrlEncoded] FormUploadFile :> Verb 'POST 200 '[JSON] ApiResponse -- 'uploadFile' route - :<|> "store" :> "order" :> Capture "orderId" Text :> Verb 'DELETE 200 '[JSON] () -- 'deleteOrder' route + :<|> "store" :> "order" :> Capture "orderId" Text :> Verb 'DELETE 200 '[JSON] NoContent -- 'deleteOrder' route :<|> "store" :> "inventory" :> Verb 'GET 200 '[JSON] ((Map.Map String Int)) -- 'getInventory' route :<|> "store" :> "order" :> Capture "orderId" Integer :> Verb 'GET 200 '[JSON] Order -- 'getOrderById' route :<|> "store" :> "order" :> ReqBody '[JSON] Order :> Verb 'POST 200 '[JSON] Order -- 'placeOrder' route - :<|> "user" :> ReqBody '[JSON] User :> Verb 'POST 200 '[JSON] () -- 'createUser' route - :<|> "user" :> "createWithArray" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] () -- 'createUsersWithArrayInput' route - :<|> "user" :> "createWithList" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] () -- 'createUsersWithListInput' route - :<|> "user" :> Capture "username" Text :> Verb 'DELETE 200 '[JSON] () -- 'deleteUser' route + :<|> "user" :> ReqBody '[JSON] User :> Verb 'POST 200 '[JSON] NoContent -- 'createUser' route + :<|> "user" :> "createWithArray" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] NoContent -- 'createUsersWithArrayInput' route + :<|> "user" :> "createWithList" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] NoContent -- 'createUsersWithListInput' route + :<|> "user" :> Capture "username" Text :> Verb 'DELETE 200 '[JSON] NoContent -- 'deleteUser' route :<|> "user" :> Capture "username" Text :> Verb 'GET 200 '[JSON] User -- 'getUserByName' route :<|> "user" :> "login" :> QueryParam "username" Text :> QueryParam "password" Text :> Verb 'GET 200 '[JSON] Text -- 'loginUser' route - :<|> "user" :> "logout" :> Verb 'GET 200 '[JSON] () -- 'logoutUser' route - :<|> "user" :> Capture "username" Text :> ReqBody '[JSON] User :> Verb 'PUT 200 '[JSON] () -- 'updateUser' route + :<|> "user" :> "logout" :> Verb 'GET 200 '[JSON] NoContent -- 'logoutUser' route + :<|> "user" :> Capture "username" Text :> ReqBody '[JSON] User :> Verb 'PUT 200 '[JSON] NoContent -- 'updateUser' route :<|> Raw @@ -177,26 +177,26 @@ newtype OpenAPIPetstoreClientError = OpenAPIPetstoreClientError ClientError -- is a backend that executes actions by sending HTTP requests (see @createOpenAPIPetstoreClient@). Alternatively, provided -- a backend, the API can be served using @runOpenAPIPetstoreMiddlewareServer@. data OpenAPIPetstoreBackend m = OpenAPIPetstoreBackend - { addPet :: Pet -> m (){- ^ -} - , deletePet :: Integer -> Maybe Text -> m (){- ^ -} + { addPet :: Pet -> m NoContent{- ^ -} + , deletePet :: Integer -> Maybe Text -> m NoContent{- ^ -} , findPetsByStatus :: Maybe [Text] -> m [Pet]{- ^ Multiple status values can be provided with comma separated strings -} , findPetsByTags :: Maybe [Text] -> m [Pet]{- ^ Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing. -} , getPetById :: Integer -> m Pet{- ^ Returns a single pet -} - , updatePet :: Pet -> m (){- ^ -} - , updatePetWithForm :: Integer -> FormUpdatePetWithForm -> m (){- ^ -} + , updatePet :: Pet -> m NoContent{- ^ -} + , updatePetWithForm :: Integer -> FormUpdatePetWithForm -> m NoContent{- ^ -} , uploadFile :: Integer -> FormUploadFile -> m ApiResponse{- ^ -} - , deleteOrder :: Text -> m (){- ^ For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors -} + , deleteOrder :: Text -> m NoContent{- ^ For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors -} , getInventory :: m ((Map.Map String Int)){- ^ Returns a map of status codes to quantities -} , getOrderById :: Integer -> m Order{- ^ For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions -} , placeOrder :: Order -> m Order{- ^ -} - , createUser :: User -> m (){- ^ This can only be done by the logged in user. -} - , createUsersWithArrayInput :: [User] -> m (){- ^ -} - , createUsersWithListInput :: [User] -> m (){- ^ -} - , deleteUser :: Text -> m (){- ^ This can only be done by the logged in user. -} + , createUser :: User -> m NoContent{- ^ This can only be done by the logged in user. -} + , createUsersWithArrayInput :: [User] -> m NoContent{- ^ -} + , createUsersWithListInput :: [User] -> m NoContent{- ^ -} + , deleteUser :: Text -> m NoContent{- ^ This can only be done by the logged in user. -} , getUserByName :: Text -> m User{- ^ -} , loginUser :: Maybe Text -> Maybe Text -> m Text{- ^ -} - , logoutUser :: m (){- ^ -} - , updateUser :: Text -> User -> m (){- ^ This can only be done by the logged in user. -} + , logoutUser :: m NoContent{- ^ -} + , updateUser :: Text -> User -> m NoContent{- ^ This can only be done by the logged in user. -} } newtype OpenAPIPetstoreClient a = OpenAPIPetstoreClient