forked from loafle/openapi-generator-original
ensure haskell, erlang server samles up-to-date (#9851)
This commit is contained in:
parent
1cd1001e34
commit
919945b65b
1
.gitignore
vendored
1
.gitignore
vendored
@ -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/haddock-bundle.min.js
|
||||||
samples/client/petstore/haskell-http-client/docs/meta.json
|
samples/client/petstore/haskell-http-client/docs/meta.json
|
||||||
samples/client/petstore/haskell-http-client/docs/quick-jump.css
|
samples/client/petstore/haskell-http-client/docs/quick-jump.css
|
||||||
|
samples/server/petstore/haskell-servant/stack.yaml.lock
|
||||||
|
|
||||||
# R
|
# R
|
||||||
.Rproj.user
|
.Rproj.user
|
||||||
|
@ -1 +1 @@
|
|||||||
5.1.1-SNAPSHOT
|
5.2.0-SNAPSHOT
|
@ -98,11 +98,7 @@ export class PetApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
if (this.configuration && this.configuration.accessToken) {
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
// oauth required
|
// oauth required
|
||||||
if (typeof this.configuration.accessToken === 'function') {
|
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
|
||||||
} else {
|
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.request({
|
const response = await this.request({
|
||||||
@ -141,11 +137,7 @@ export class PetApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
if (this.configuration && this.configuration.accessToken) {
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
// oauth required
|
// oauth required
|
||||||
if (typeof this.configuration.accessToken === 'function') {
|
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
|
||||||
} else {
|
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.request({
|
const response = await this.request({
|
||||||
@ -184,11 +176,7 @@ export class PetApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
if (this.configuration && this.configuration.accessToken) {
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
// oauth required
|
// oauth required
|
||||||
if (typeof this.configuration.accessToken === 'function') {
|
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
|
||||||
} else {
|
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.request({
|
const response = await this.request({
|
||||||
@ -229,11 +217,7 @@ export class PetApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
if (this.configuration && this.configuration.accessToken) {
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
// oauth required
|
// oauth required
|
||||||
if (typeof this.configuration.accessToken === 'function') {
|
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
|
||||||
} else {
|
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.request({
|
const response = await this.request({
|
||||||
@ -274,11 +258,7 @@ export class PetApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
if (this.configuration && this.configuration.accessToken) {
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
// oauth required
|
// oauth required
|
||||||
if (typeof this.configuration.accessToken === 'function') {
|
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
|
||||||
} else {
|
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.request({
|
const response = await this.request({
|
||||||
@ -319,11 +299,7 @@ export class PetApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
if (this.configuration && this.configuration.accessToken) {
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
// oauth required
|
// oauth required
|
||||||
if (typeof this.configuration.accessToken === 'function') {
|
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
|
||||||
} else {
|
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.request({
|
const response = await this.request({
|
||||||
@ -397,11 +373,7 @@ export class PetApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
if (this.configuration && this.configuration.accessToken) {
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
// oauth required
|
// oauth required
|
||||||
if (typeof this.configuration.accessToken === 'function') {
|
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
|
||||||
} else {
|
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await this.request({
|
const response = await this.request({
|
||||||
@ -436,11 +408,7 @@ export class PetApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
if (this.configuration && this.configuration.accessToken) {
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
// oauth required
|
// oauth required
|
||||||
if (typeof this.configuration.accessToken === 'function') {
|
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
|
||||||
} else {
|
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const consumes: runtime.Consume[] = [
|
const consumes: runtime.Consume[] = [
|
||||||
@ -497,11 +465,7 @@ export class PetApi extends runtime.BaseAPI {
|
|||||||
|
|
||||||
if (this.configuration && this.configuration.accessToken) {
|
if (this.configuration && this.configuration.accessToken) {
|
||||||
// oauth required
|
// oauth required
|
||||||
if (typeof this.configuration.accessToken === 'function') {
|
headerParameters["Authorization"] = await this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken("petstore_auth", ["write:pets", "read:pets"]);
|
|
||||||
} else {
|
|
||||||
headerParameters["Authorization"] = this.configuration.accessToken;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const consumes: runtime.Consume[] = [
|
const consumes: runtime.Consume[] = [
|
||||||
|
@ -90,8 +90,8 @@ export class BaseAPI {
|
|||||||
if (middleware.post) {
|
if (middleware.post) {
|
||||||
response = await middleware.post({
|
response = await middleware.post({
|
||||||
fetch: this.fetchApi,
|
fetch: this.fetchApi,
|
||||||
url,
|
url: fetchParams.url,
|
||||||
init,
|
init: fetchParams.init,
|
||||||
response: response.clone(),
|
response: response.clone(),
|
||||||
}) || response;
|
}) || response;
|
||||||
}
|
}
|
||||||
@ -135,7 +135,7 @@ export interface ConfigurationParameters {
|
|||||||
username?: string; // parameter for basic security
|
username?: string; // parameter for basic security
|
||||||
password?: string; // parameter for basic security
|
password?: string; // parameter for basic security
|
||||||
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
apiKey?: string | ((name: string) => string); // parameter for apiKey security
|
||||||
accessToken?: string | ((name?: string, scopes?: string[]) => string); // parameter for oauth2 security
|
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string | Promise<string>); // parameter for oauth2 security
|
||||||
headers?: HTTPHeaders; //header params we want to use on every request
|
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
|
credentials?: RequestCredentials; //value for the credentials param we want to use on each request
|
||||||
}
|
}
|
||||||
@ -175,10 +175,10 @@ export class Configuration {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
get accessToken(): ((name: string, scopes?: string[]) => string) | undefined {
|
get accessToken(): ((name?: string, scopes?: string[]) => string | Promise<string>) | undefined {
|
||||||
const accessToken = this.configuration.accessToken;
|
const accessToken = this.configuration.accessToken;
|
||||||
if (accessToken) {
|
if (accessToken) {
|
||||||
return typeof accessToken === 'function' ? accessToken : () => accessToken;
|
return typeof accessToken === 'function' ? accessToken : async () => accessToken;
|
||||||
}
|
}
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,6 @@
|
|||||||
|
README.md
|
||||||
|
Setup.hs
|
||||||
|
lib/OpenAPIPetstore/API.hs
|
||||||
|
lib/OpenAPIPetstore/Types.hs
|
||||||
|
openapi-petstore.cabal
|
||||||
|
stack.yaml
|
@ -137,26 +137,26 @@ formatSeparatedQueryList char = T.intercalate (T.singleton char) . map toQueryPa
|
|||||||
|
|
||||||
-- | Servant type-level API, generated from the OpenAPI spec for OpenAPIPetstore.
|
-- | Servant type-level API, generated from the OpenAPI spec for OpenAPIPetstore.
|
||||||
type OpenAPIPetstoreAPI
|
type OpenAPIPetstoreAPI
|
||||||
= "pet" :> ReqBody '[JSON] Pet :> Verb 'POST 200 '[JSON] () -- 'addPet' route
|
= "pet" :> ReqBody '[JSON] Pet :> Verb 'POST 200 '[JSON] NoContent -- 'addPet' route
|
||||||
:<|> "pet" :> Capture "petId" Integer :> Header "api_key" Text :> Verb 'DELETE 200 '[JSON] () -- 'deletePet' 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" :> "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" :> "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" :> Capture "petId" Integer :> Verb 'GET 200 '[JSON] Pet -- 'getPetById' route
|
||||||
:<|> "pet" :> ReqBody '[JSON] Pet :> Verb 'PUT 200 '[JSON] () -- 'updatePet' route
|
:<|> "pet" :> ReqBody '[JSON] Pet :> Verb 'PUT 200 '[JSON] NoContent -- 'updatePet' route
|
||||||
:<|> "pet" :> Capture "petId" Integer :> ReqBody '[FormUrlEncoded] FormUpdatePetWithForm :> Verb 'POST 200 '[JSON] () -- 'updatePetWithForm' 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
|
:<|> "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" :> "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" :> Capture "orderId" Integer :> Verb 'GET 200 '[JSON] Order -- 'getOrderById' route
|
||||||
:<|> "store" :> "order" :> ReqBody '[JSON] Order :> Verb 'POST 200 '[JSON] Order -- 'placeOrder' route
|
:<|> "store" :> "order" :> ReqBody '[JSON] Order :> Verb 'POST 200 '[JSON] Order -- 'placeOrder' route
|
||||||
:<|> "user" :> ReqBody '[JSON] User :> Verb 'POST 200 '[JSON] () -- 'createUser' route
|
:<|> "user" :> ReqBody '[JSON] User :> Verb 'POST 200 '[JSON] NoContent -- 'createUser' route
|
||||||
:<|> "user" :> "createWithArray" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] () -- 'createUsersWithArrayInput' route
|
:<|> "user" :> "createWithArray" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] NoContent -- 'createUsersWithArrayInput' route
|
||||||
:<|> "user" :> "createWithList" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] () -- 'createUsersWithListInput' route
|
:<|> "user" :> "createWithList" :> ReqBody '[JSON] [User] :> Verb 'POST 200 '[JSON] NoContent -- 'createUsersWithListInput' route
|
||||||
:<|> "user" :> Capture "username" Text :> Verb 'DELETE 200 '[JSON] () -- 'deleteUser' route
|
:<|> "user" :> Capture "username" Text :> Verb 'DELETE 200 '[JSON] NoContent -- 'deleteUser' route
|
||||||
:<|> "user" :> Capture "username" Text :> Verb 'GET 200 '[JSON] User -- 'getUserByName' 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" :> "login" :> QueryParam "username" Text :> QueryParam "password" Text :> Verb 'GET 200 '[JSON] Text -- 'loginUser' route
|
||||||
:<|> "user" :> "logout" :> Verb 'GET 200 '[JSON] () -- 'logoutUser' route
|
:<|> "user" :> "logout" :> Verb 'GET 200 '[JSON] NoContent -- 'logoutUser' route
|
||||||
:<|> "user" :> Capture "username" Text :> ReqBody '[JSON] User :> Verb 'PUT 200 '[JSON] () -- 'updateUser' route
|
:<|> "user" :> Capture "username" Text :> ReqBody '[JSON] User :> Verb 'PUT 200 '[JSON] NoContent -- 'updateUser' route
|
||||||
:<|> Raw
|
:<|> Raw
|
||||||
|
|
||||||
|
|
||||||
@ -177,26 +177,26 @@ newtype OpenAPIPetstoreClientError = OpenAPIPetstoreClientError ClientError
|
|||||||
-- is a backend that executes actions by sending HTTP requests (see @createOpenAPIPetstoreClient@). Alternatively, provided
|
-- is a backend that executes actions by sending HTTP requests (see @createOpenAPIPetstoreClient@). Alternatively, provided
|
||||||
-- a backend, the API can be served using @runOpenAPIPetstoreMiddlewareServer@.
|
-- a backend, the API can be served using @runOpenAPIPetstoreMiddlewareServer@.
|
||||||
data OpenAPIPetstoreBackend m = OpenAPIPetstoreBackend
|
data OpenAPIPetstoreBackend m = OpenAPIPetstoreBackend
|
||||||
{ addPet :: Pet -> m (){- ^ -}
|
{ addPet :: Pet -> m NoContent{- ^ -}
|
||||||
, deletePet :: Integer -> Maybe Text -> m (){- ^ -}
|
, deletePet :: Integer -> Maybe Text -> m NoContent{- ^ -}
|
||||||
, findPetsByStatus :: Maybe [Text] -> m [Pet]{- ^ Multiple status values can be provided with comma separated strings -}
|
, 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. -}
|
, 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 -}
|
, getPetById :: Integer -> m Pet{- ^ Returns a single pet -}
|
||||||
, updatePet :: Pet -> m (){- ^ -}
|
, updatePet :: Pet -> m NoContent{- ^ -}
|
||||||
, updatePetWithForm :: Integer -> FormUpdatePetWithForm -> m (){- ^ -}
|
, updatePetWithForm :: Integer -> FormUpdatePetWithForm -> m NoContent{- ^ -}
|
||||||
, uploadFile :: Integer -> FormUploadFile -> m ApiResponse{- ^ -}
|
, 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 -}
|
, 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 -}
|
, getOrderById :: Integer -> m Order{- ^ For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions -}
|
||||||
, placeOrder :: Order -> m Order{- ^ -}
|
, placeOrder :: Order -> m Order{- ^ -}
|
||||||
, createUser :: User -> 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 (){- ^ -}
|
, createUsersWithArrayInput :: [User] -> m NoContent{- ^ -}
|
||||||
, createUsersWithListInput :: [User] -> m (){- ^ -}
|
, createUsersWithListInput :: [User] -> m NoContent{- ^ -}
|
||||||
, deleteUser :: Text -> m (){- ^ This can only be done by the logged in user. -}
|
, deleteUser :: Text -> m NoContent{- ^ This can only be done by the logged in user. -}
|
||||||
, getUserByName :: Text -> m User{- ^ -}
|
, getUserByName :: Text -> m User{- ^ -}
|
||||||
, loginUser :: Maybe Text -> Maybe Text -> m Text{- ^ -}
|
, loginUser :: Maybe Text -> Maybe Text -> m Text{- ^ -}
|
||||||
, logoutUser :: m (){- ^ -}
|
, logoutUser :: m NoContent{- ^ -}
|
||||||
, updateUser :: Text -> User -> m (){- ^ This can only be done by the logged in user. -}
|
, updateUser :: Text -> User -> m NoContent{- ^ This can only be done by the logged in user. -}
|
||||||
}
|
}
|
||||||
|
|
||||||
newtype OpenAPIPetstoreClient a = OpenAPIPetstoreClient
|
newtype OpenAPIPetstoreClient a = OpenAPIPetstoreClient
|
||||||
|
Loading…
x
Reference in New Issue
Block a user