forked from loafle/openapi-generator-original
Add F# Functions server generator (#3933)
* cherry pick F# Functions generator test fix fix template paths replace giraffe sample * update doc
This commit is contained in:
committed by
William Cheng
parent
252c3e58be
commit
8408232d1a
@@ -0,0 +1,193 @@
|
||||
namespace OpenAPI
|
||||
|
||||
open PetApiHandlerParams
|
||||
open PetApiServiceImplementation
|
||||
open Microsoft.AspNetCore.Mvc
|
||||
open Microsoft.AspNetCore.Http
|
||||
open Newtonsoft.Json
|
||||
open Microsoft.Azure.WebJobs
|
||||
open System.IO
|
||||
|
||||
module PetApiHandlers =
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
//#region AddPet
|
||||
/// <summary>
|
||||
/// Add a new pet to the store
|
||||
/// </summary>
|
||||
[<FunctionName("AddPet")>]
|
||||
let AddPet
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "POST", Route = "/v2/pet")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
use reader = StreamReader(req.Body)
|
||||
|
||||
let mediaTypes = ["application/json";"application/xml";] // currently unused
|
||||
|
||||
let bind (contentType:string) body =
|
||||
match (contentType.ToLower()) with
|
||||
| "application/json" ->
|
||||
body |> JsonConvert.DeserializeObject<AddPetBodyParams>
|
||||
| _ -> failwith (sprintf "TODO - ContentType %s not currently supported" contentType)
|
||||
|
||||
let bodyParams = reader.ReadToEnd() |> bind req.ContentType
|
||||
let result = PetApiService.AddPet bodyParams
|
||||
match result with
|
||||
| AddPetStatusCode405 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(405))
|
||||
|
||||
//#region DeletePet
|
||||
/// <summary>
|
||||
/// Deletes a pet
|
||||
/// </summary>
|
||||
[<FunctionName("DeletePet")>]
|
||||
let DeletePet
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "DELETE", Route = "/v2/pet/{petId}")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = PetApiService.DeletePet ()
|
||||
match result with
|
||||
| DeletePetStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
|
||||
//#region FindPetsByStatus
|
||||
/// <summary>
|
||||
/// Finds Pets by status
|
||||
/// </summary>
|
||||
[<FunctionName("FindPetsByStatus")>]
|
||||
let FindPetsByStatus
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "GET", Route = "/v2/pet/findByStatus")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = PetApiService.FindPetsByStatus ()
|
||||
match result with
|
||||
| FindPetsByStatusDefaultStatusCode resolved ->
|
||||
let content = JsonConvert.SerializeObject resolved.content
|
||||
let responseContentType = "application/json"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(200))
|
||||
| FindPetsByStatusStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
|
||||
//#region FindPetsByTags
|
||||
/// <summary>
|
||||
/// Finds Pets by tags
|
||||
/// </summary>
|
||||
[<FunctionName("FindPetsByTags")>]
|
||||
let FindPetsByTags
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "GET", Route = "/v2/pet/findByTags")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = PetApiService.FindPetsByTags ()
|
||||
match result with
|
||||
| FindPetsByTagsDefaultStatusCode resolved ->
|
||||
let content = JsonConvert.SerializeObject resolved.content
|
||||
let responseContentType = "application/json"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(200))
|
||||
| FindPetsByTagsStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
|
||||
//#region GetPetById
|
||||
/// <summary>
|
||||
/// Find pet by ID
|
||||
/// </summary>
|
||||
[<FunctionName("GetPetById")>]
|
||||
let GetPetById
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "GET", Route = "/v2/pet/{petId}")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = PetApiService.GetPetById ()
|
||||
match result with
|
||||
| GetPetByIdDefaultStatusCode resolved ->
|
||||
let content = JsonConvert.SerializeObject resolved.content
|
||||
let responseContentType = "application/json"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(200))
|
||||
| GetPetByIdStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
| GetPetByIdStatusCode404 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(404))
|
||||
|
||||
//#region UpdatePet
|
||||
/// <summary>
|
||||
/// Update an existing pet
|
||||
/// </summary>
|
||||
[<FunctionName("UpdatePet")>]
|
||||
let UpdatePet
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "PUT", Route = "/v2/pet")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
use reader = StreamReader(req.Body)
|
||||
|
||||
let mediaTypes = ["application/json";"application/xml";] // currently unused
|
||||
|
||||
let bind (contentType:string) body =
|
||||
match (contentType.ToLower()) with
|
||||
| "application/json" ->
|
||||
body |> JsonConvert.DeserializeObject<UpdatePetBodyParams>
|
||||
| _ -> failwith (sprintf "TODO - ContentType %s not currently supported" contentType)
|
||||
|
||||
let bodyParams = reader.ReadToEnd() |> bind req.ContentType
|
||||
let result = PetApiService.UpdatePet bodyParams
|
||||
match result with
|
||||
| UpdatePetStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
| UpdatePetStatusCode404 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(404))
|
||||
| UpdatePetStatusCode405 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(405))
|
||||
|
||||
//#region UpdatePetWithForm
|
||||
/// <summary>
|
||||
/// Updates a pet in the store with form data
|
||||
/// </summary>
|
||||
[<FunctionName("UpdatePetWithForm")>]
|
||||
let UpdatePetWithForm
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "POST", Route = "/v2/pet/{petId}")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = PetApiService.UpdatePetWithForm ()
|
||||
match result with
|
||||
| UpdatePetWithFormStatusCode405 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(405))
|
||||
|
||||
//#region UploadFile
|
||||
/// <summary>
|
||||
/// uploads an image
|
||||
/// </summary>
|
||||
[<FunctionName("UploadFile")>]
|
||||
let UploadFile
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "POST", Route = "/v2/pet/{petId}/uploadImage")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = PetApiService.UploadFile ()
|
||||
match result with
|
||||
| UploadFileDefaultStatusCode resolved ->
|
||||
let content = JsonConvert.SerializeObject resolved.content
|
||||
let responseContentType = "application/json"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(200))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,210 @@
|
||||
namespace OpenAPI
|
||||
|
||||
open OpenAPI.Model.ApiResponse
|
||||
open OpenAPI.Model.Pet
|
||||
open System.Collections.Generic
|
||||
open System
|
||||
|
||||
module PetApiHandlerParams =
|
||||
|
||||
|
||||
//#region Body parameters
|
||||
[<CLIMutable>]
|
||||
type AddPetBodyParams = Pet
|
||||
//#endregion
|
||||
|
||||
|
||||
type AddPetStatusCode405Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type AddPetResult = AddPetStatusCode405 of AddPetStatusCode405Response
|
||||
|
||||
type AddPetArgs = {
|
||||
bodyParams:AddPetBodyParams
|
||||
}
|
||||
//#region Path parameters
|
||||
[<CLIMutable>]
|
||||
type DeletePetPathParams = {
|
||||
petId : int64 ;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region Header parameters
|
||||
[<CLIMutable>]
|
||||
type DeletePetHeaderParams = {
|
||||
apiKey : string option;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
type DeletePetStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type DeletePetResult = DeletePetStatusCode400 of DeletePetStatusCode400Response
|
||||
|
||||
type DeletePetArgs = {
|
||||
headerParams:DeletePetHeaderParams;
|
||||
pathParams:DeletePetPathParams;
|
||||
}
|
||||
|
||||
//#region Query parameters
|
||||
[<CLIMutable>]
|
||||
type FindPetsByStatusQueryParams = {
|
||||
status : string[] ;
|
||||
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
type FindPetsByStatusDefaultStatusCodeResponse = {
|
||||
content:Pet[];
|
||||
|
||||
}
|
||||
|
||||
type FindPetsByStatusStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type FindPetsByStatusResult = FindPetsByStatusDefaultStatusCode of FindPetsByStatusDefaultStatusCodeResponse|FindPetsByStatusStatusCode400 of FindPetsByStatusStatusCode400Response
|
||||
|
||||
type FindPetsByStatusArgs = {
|
||||
queryParams:Result<FindPetsByStatusQueryParams,string>;
|
||||
}
|
||||
|
||||
//#region Query parameters
|
||||
[<CLIMutable>]
|
||||
type FindPetsByTagsQueryParams = {
|
||||
tags : string[] ;
|
||||
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
type FindPetsByTagsDefaultStatusCodeResponse = {
|
||||
content:Pet[];
|
||||
|
||||
}
|
||||
|
||||
type FindPetsByTagsStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type FindPetsByTagsResult = FindPetsByTagsDefaultStatusCode of FindPetsByTagsDefaultStatusCodeResponse|FindPetsByTagsStatusCode400 of FindPetsByTagsStatusCode400Response
|
||||
|
||||
type FindPetsByTagsArgs = {
|
||||
queryParams:Result<FindPetsByTagsQueryParams,string>;
|
||||
}
|
||||
//#region Path parameters
|
||||
[<CLIMutable>]
|
||||
type GetPetByIdPathParams = {
|
||||
petId : int64 ;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
type GetPetByIdDefaultStatusCodeResponse = {
|
||||
content:Pet;
|
||||
|
||||
}
|
||||
|
||||
type GetPetByIdStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
|
||||
type GetPetByIdStatusCode404Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type GetPetByIdResult = GetPetByIdDefaultStatusCode of GetPetByIdDefaultStatusCodeResponse|GetPetByIdStatusCode400 of GetPetByIdStatusCode400Response|GetPetByIdStatusCode404 of GetPetByIdStatusCode404Response
|
||||
|
||||
type GetPetByIdArgs = {
|
||||
pathParams:GetPetByIdPathParams;
|
||||
}
|
||||
|
||||
//#region Body parameters
|
||||
[<CLIMutable>]
|
||||
type UpdatePetBodyParams = Pet
|
||||
//#endregion
|
||||
|
||||
|
||||
type UpdatePetStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
|
||||
type UpdatePetStatusCode404Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
|
||||
type UpdatePetStatusCode405Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type UpdatePetResult = UpdatePetStatusCode400 of UpdatePetStatusCode400Response|UpdatePetStatusCode404 of UpdatePetStatusCode404Response|UpdatePetStatusCode405 of UpdatePetStatusCode405Response
|
||||
|
||||
type UpdatePetArgs = {
|
||||
bodyParams:UpdatePetBodyParams
|
||||
}
|
||||
//#region Path parameters
|
||||
[<CLIMutable>]
|
||||
type UpdatePetWithFormPathParams = {
|
||||
petId : int64 ;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region Form parameters
|
||||
[<CLIMutable>]
|
||||
type UpdatePetWithFormFormParams = {
|
||||
name : string option;
|
||||
//#endregion
|
||||
|
||||
//#region Form parameters
|
||||
status : string option;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
type UpdatePetWithFormStatusCode405Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type UpdatePetWithFormResult = UpdatePetWithFormStatusCode405 of UpdatePetWithFormStatusCode405Response
|
||||
|
||||
type UpdatePetWithFormArgs = {
|
||||
pathParams:UpdatePetWithFormPathParams;
|
||||
formParams:Result<UpdatePetWithFormFormParams,string>
|
||||
}
|
||||
//#region Path parameters
|
||||
[<CLIMutable>]
|
||||
type UploadFilePathParams = {
|
||||
petId : int64 ;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region Form parameters
|
||||
[<CLIMutable>]
|
||||
type UploadFileFormParams = {
|
||||
additionalMetadata : string option;
|
||||
//#endregion
|
||||
|
||||
//#region Form parameters
|
||||
file : System.IO.Stream option;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
type UploadFileDefaultStatusCodeResponse = {
|
||||
content:ApiResponse;
|
||||
|
||||
}
|
||||
type UploadFileResult = UploadFileDefaultStatusCode of UploadFileDefaultStatusCodeResponse
|
||||
|
||||
type UploadFileArgs = {
|
||||
pathParams:UploadFilePathParams;
|
||||
formParams:Result<UploadFileFormParams,string>
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace OpenAPI
|
||||
open PetApiHandlerParams
|
||||
open System
|
||||
open Microsoft.AspNetCore.Http
|
||||
|
||||
|
||||
module PetApiServiceInterface =
|
||||
|
||||
//#region Service interface
|
||||
type IPetApiService =
|
||||
abstract member AddPet : AddPetBodyParams -> AddPetResult
|
||||
abstract member DeletePet : unit -> DeletePetResult
|
||||
abstract member FindPetsByStatus : unit -> FindPetsByStatusResult
|
||||
abstract member FindPetsByTags : unit -> FindPetsByTagsResult
|
||||
abstract member GetPetById : unit -> GetPetByIdResult
|
||||
abstract member UpdatePet : UpdatePetBodyParams -> UpdatePetResult
|
||||
abstract member UpdatePetWithForm : unit -> UpdatePetWithFormResult
|
||||
abstract member UploadFile : unit -> UploadFileResult
|
||||
//#endregion
|
||||
@@ -0,0 +1,110 @@
|
||||
namespace OpenAPI
|
||||
|
||||
open StoreApiHandlerParams
|
||||
open StoreApiServiceImplementation
|
||||
open Microsoft.AspNetCore.Mvc
|
||||
open Microsoft.AspNetCore.Http
|
||||
open Newtonsoft.Json
|
||||
open Microsoft.Azure.WebJobs
|
||||
open System.IO
|
||||
|
||||
module StoreApiHandlers =
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
//#region DeleteOrder
|
||||
/// <summary>
|
||||
/// Delete purchase order by ID
|
||||
/// </summary>
|
||||
[<FunctionName("DeleteOrder")>]
|
||||
let DeleteOrder
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "DELETE", Route = "/v2/store/order/{orderId}")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = StoreApiService.DeleteOrder ()
|
||||
match result with
|
||||
| DeleteOrderStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
| DeleteOrderStatusCode404 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(404))
|
||||
|
||||
//#region GetInventory
|
||||
/// <summary>
|
||||
/// Returns pet inventories by status
|
||||
/// </summary>
|
||||
[<FunctionName("GetInventory")>]
|
||||
let GetInventory
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "GET", Route = "/v2/store/inventory")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = StoreApiService.GetInventory ()
|
||||
match result with
|
||||
| GetInventoryDefaultStatusCode resolved ->
|
||||
let content = JsonConvert.SerializeObject resolved.content
|
||||
let responseContentType = "application/json"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(200))
|
||||
|
||||
//#region GetOrderById
|
||||
/// <summary>
|
||||
/// Find purchase order by ID
|
||||
/// </summary>
|
||||
[<FunctionName("GetOrderById")>]
|
||||
let GetOrderById
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "GET", Route = "/v2/store/order/{orderId}")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = StoreApiService.GetOrderById ()
|
||||
match result with
|
||||
| GetOrderByIdDefaultStatusCode resolved ->
|
||||
let content = JsonConvert.SerializeObject resolved.content
|
||||
let responseContentType = "application/json"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(200))
|
||||
| GetOrderByIdStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
| GetOrderByIdStatusCode404 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(404))
|
||||
|
||||
//#region PlaceOrder
|
||||
/// <summary>
|
||||
/// Place an order for a pet
|
||||
/// </summary>
|
||||
[<FunctionName("PlaceOrder")>]
|
||||
let PlaceOrder
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "POST", Route = "/v2/store/order")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
use reader = StreamReader(req.Body)
|
||||
|
||||
let mediaTypes = [] // currently unused
|
||||
|
||||
let bind (contentType:string) body =
|
||||
match (contentType.ToLower()) with
|
||||
| "application/json" ->
|
||||
body |> JsonConvert.DeserializeObject<PlaceOrderBodyParams>
|
||||
| _ -> failwith (sprintf "TODO - ContentType %s not currently supported" contentType)
|
||||
|
||||
let bodyParams = reader.ReadToEnd() |> bind req.ContentType
|
||||
let result = StoreApiService.PlaceOrder bodyParams
|
||||
match result with
|
||||
| PlaceOrderDefaultStatusCode resolved ->
|
||||
let content = JsonConvert.SerializeObject resolved.content
|
||||
let responseContentType = "application/json"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(200))
|
||||
| PlaceOrderStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,88 @@
|
||||
namespace OpenAPI
|
||||
|
||||
open System.Collections.Generic
|
||||
open OpenAPI.Model.Order
|
||||
open System.Collections.Generic
|
||||
open System
|
||||
|
||||
module StoreApiHandlerParams =
|
||||
|
||||
//#region Path parameters
|
||||
[<CLIMutable>]
|
||||
type DeleteOrderPathParams = {
|
||||
orderId : string ;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
type DeleteOrderStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
|
||||
type DeleteOrderStatusCode404Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type DeleteOrderResult = DeleteOrderStatusCode400 of DeleteOrderStatusCode400Response|DeleteOrderStatusCode404 of DeleteOrderStatusCode404Response
|
||||
|
||||
type DeleteOrderArgs = {
|
||||
pathParams:DeleteOrderPathParams;
|
||||
}
|
||||
|
||||
|
||||
type GetInventoryDefaultStatusCodeResponse = {
|
||||
content:IDictionary<string, int>;
|
||||
|
||||
}
|
||||
type GetInventoryResult = GetInventoryDefaultStatusCode of GetInventoryDefaultStatusCodeResponse
|
||||
|
||||
//#region Path parameters
|
||||
[<CLIMutable>]
|
||||
type GetOrderByIdPathParams = {
|
||||
orderId : int64 ;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
type GetOrderByIdDefaultStatusCodeResponse = {
|
||||
content:Order;
|
||||
|
||||
}
|
||||
|
||||
type GetOrderByIdStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
|
||||
type GetOrderByIdStatusCode404Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type GetOrderByIdResult = GetOrderByIdDefaultStatusCode of GetOrderByIdDefaultStatusCodeResponse|GetOrderByIdStatusCode400 of GetOrderByIdStatusCode400Response|GetOrderByIdStatusCode404 of GetOrderByIdStatusCode404Response
|
||||
|
||||
type GetOrderByIdArgs = {
|
||||
pathParams:GetOrderByIdPathParams;
|
||||
}
|
||||
|
||||
//#region Body parameters
|
||||
[<CLIMutable>]
|
||||
type PlaceOrderBodyParams = Order
|
||||
//#endregion
|
||||
|
||||
|
||||
type PlaceOrderDefaultStatusCodeResponse = {
|
||||
content:Order;
|
||||
|
||||
}
|
||||
|
||||
type PlaceOrderStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type PlaceOrderResult = PlaceOrderDefaultStatusCode of PlaceOrderDefaultStatusCodeResponse|PlaceOrderStatusCode400 of PlaceOrderStatusCode400Response
|
||||
|
||||
type PlaceOrderArgs = {
|
||||
bodyParams:PlaceOrderBodyParams
|
||||
}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
namespace OpenAPI
|
||||
open StoreApiHandlerParams
|
||||
open System
|
||||
open Microsoft.AspNetCore.Http
|
||||
|
||||
|
||||
module StoreApiServiceInterface =
|
||||
|
||||
//#region Service interface
|
||||
type IStoreApiService =
|
||||
abstract member DeleteOrder : unit -> DeleteOrderResult
|
||||
abstract member GetInventory : unit -> GetInventoryResult
|
||||
abstract member GetOrderById : unit -> GetOrderByIdResult
|
||||
abstract member PlaceOrder : PlaceOrderBodyParams -> PlaceOrderResult
|
||||
//#endregion
|
||||
@@ -0,0 +1,211 @@
|
||||
namespace OpenAPI
|
||||
|
||||
open UserApiHandlerParams
|
||||
open UserApiServiceImplementation
|
||||
open Microsoft.AspNetCore.Mvc
|
||||
open Microsoft.AspNetCore.Http
|
||||
open Newtonsoft.Json
|
||||
open Microsoft.Azure.WebJobs
|
||||
open System.IO
|
||||
|
||||
module UserApiHandlers =
|
||||
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
|
||||
//#region CreateUser
|
||||
/// <summary>
|
||||
/// Create user
|
||||
/// </summary>
|
||||
[<FunctionName("CreateUser")>]
|
||||
let CreateUser
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "POST", Route = "/v2/user")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
use reader = StreamReader(req.Body)
|
||||
|
||||
let mediaTypes = [] // currently unused
|
||||
|
||||
let bind (contentType:string) body =
|
||||
match (contentType.ToLower()) with
|
||||
| "application/json" ->
|
||||
body |> JsonConvert.DeserializeObject<CreateUserBodyParams>
|
||||
| _ -> failwith (sprintf "TODO - ContentType %s not currently supported" contentType)
|
||||
|
||||
let bodyParams = reader.ReadToEnd() |> bind req.ContentType
|
||||
let result = UserApiService.CreateUser bodyParams
|
||||
match result with
|
||||
| CreateUserDefaultStatusCode resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(0))
|
||||
|
||||
//#region CreateUsersWithArrayInput
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
[<FunctionName("CreateUsersWithArrayInput")>]
|
||||
let CreateUsersWithArrayInput
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "POST", Route = "/v2/user/createWithArray")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
use reader = StreamReader(req.Body)
|
||||
|
||||
let mediaTypes = [] // currently unused
|
||||
|
||||
let bind (contentType:string) body =
|
||||
match (contentType.ToLower()) with
|
||||
| "application/json" ->
|
||||
body |> JsonConvert.DeserializeObject<CreateUsersWithArrayInputBodyParams>
|
||||
| _ -> failwith (sprintf "TODO - ContentType %s not currently supported" contentType)
|
||||
|
||||
let bodyParams = reader.ReadToEnd() |> bind req.ContentType
|
||||
let result = UserApiService.CreateUsersWithArrayInput bodyParams
|
||||
match result with
|
||||
| CreateUsersWithArrayInputDefaultStatusCode resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(0))
|
||||
|
||||
//#region CreateUsersWithListInput
|
||||
/// <summary>
|
||||
/// Creates list of users with given input array
|
||||
/// </summary>
|
||||
[<FunctionName("CreateUsersWithListInput")>]
|
||||
let CreateUsersWithListInput
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "POST", Route = "/v2/user/createWithList")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
use reader = StreamReader(req.Body)
|
||||
|
||||
let mediaTypes = [] // currently unused
|
||||
|
||||
let bind (contentType:string) body =
|
||||
match (contentType.ToLower()) with
|
||||
| "application/json" ->
|
||||
body |> JsonConvert.DeserializeObject<CreateUsersWithListInputBodyParams>
|
||||
| _ -> failwith (sprintf "TODO - ContentType %s not currently supported" contentType)
|
||||
|
||||
let bodyParams = reader.ReadToEnd() |> bind req.ContentType
|
||||
let result = UserApiService.CreateUsersWithListInput bodyParams
|
||||
match result with
|
||||
| CreateUsersWithListInputDefaultStatusCode resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(0))
|
||||
|
||||
//#region DeleteUser
|
||||
/// <summary>
|
||||
/// Delete user
|
||||
/// </summary>
|
||||
[<FunctionName("DeleteUser")>]
|
||||
let DeleteUser
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "DELETE", Route = "/v2/user/{username}")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = UserApiService.DeleteUser ()
|
||||
match result with
|
||||
| DeleteUserStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
| DeleteUserStatusCode404 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(404))
|
||||
|
||||
//#region GetUserByName
|
||||
/// <summary>
|
||||
/// Get user by user name
|
||||
/// </summary>
|
||||
[<FunctionName("GetUserByName")>]
|
||||
let GetUserByName
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "GET", Route = "/v2/user/{username}")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = UserApiService.GetUserByName ()
|
||||
match result with
|
||||
| GetUserByNameDefaultStatusCode resolved ->
|
||||
let content = JsonConvert.SerializeObject resolved.content
|
||||
let responseContentType = "application/json"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(200))
|
||||
| GetUserByNameStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
| GetUserByNameStatusCode404 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(404))
|
||||
|
||||
//#region LoginUser
|
||||
/// <summary>
|
||||
/// Logs user into the system
|
||||
/// </summary>
|
||||
[<FunctionName("LoginUser")>]
|
||||
let LoginUser
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "GET", Route = "/v2/user/login")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = UserApiService.LoginUser ()
|
||||
match result with
|
||||
| LoginUserDefaultStatusCode resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(200))
|
||||
| LoginUserStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
|
||||
//#region LogoutUser
|
||||
/// <summary>
|
||||
/// Logs out current logged in user session
|
||||
/// </summary>
|
||||
[<FunctionName("LogoutUser")>]
|
||||
let LogoutUser
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "GET", Route = "/v2/user/logout")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
let result = UserApiService.LogoutUser ()
|
||||
match result with
|
||||
| LogoutUserDefaultStatusCode resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(0))
|
||||
|
||||
//#region UpdateUser
|
||||
/// <summary>
|
||||
/// Updated user
|
||||
/// </summary>
|
||||
[<FunctionName("UpdateUser")>]
|
||||
let UpdateUser
|
||||
([<HttpTrigger(Extensions.Http.AuthorizationLevel.Anonymous, "PUT", Route = "/v2/user/{username}")>]
|
||||
req:HttpRequest ) =
|
||||
|
||||
use reader = StreamReader(req.Body)
|
||||
|
||||
let mediaTypes = [] // currently unused
|
||||
|
||||
let bind (contentType:string) body =
|
||||
match (contentType.ToLower()) with
|
||||
| "application/json" ->
|
||||
body |> JsonConvert.DeserializeObject<UpdateUserBodyParams>
|
||||
| _ -> failwith (sprintf "TODO - ContentType %s not currently supported" contentType)
|
||||
|
||||
let bodyParams = reader.ReadToEnd() |> bind req.ContentType
|
||||
let result = UserApiService.UpdateUser bodyParams
|
||||
match result with
|
||||
| UpdateUserStatusCode400 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(400))
|
||||
| UpdateUserStatusCode404 resolved ->
|
||||
let content = resolved.content
|
||||
let responseContentType = "text/plain"
|
||||
ContentResult(Content = content, ContentType = responseContentType, StatusCode = System.Nullable(404))
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
namespace OpenAPI
|
||||
|
||||
open OpenAPI.Model.User
|
||||
open System.Collections.Generic
|
||||
open System
|
||||
|
||||
module UserApiHandlerParams =
|
||||
|
||||
|
||||
//#region Body parameters
|
||||
[<CLIMutable>]
|
||||
type CreateUserBodyParams = User
|
||||
//#endregion
|
||||
|
||||
|
||||
type CreateUserDefaultStatusCodeResponse = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type CreateUserResult = CreateUserDefaultStatusCode of CreateUserDefaultStatusCodeResponse
|
||||
|
||||
type CreateUserArgs = {
|
||||
bodyParams:CreateUserBodyParams
|
||||
}
|
||||
|
||||
//#region Body parameters
|
||||
[<CLIMutable>]
|
||||
type CreateUsersWithArrayInputBodyParams = User[]
|
||||
//#endregion
|
||||
|
||||
|
||||
type CreateUsersWithArrayInputDefaultStatusCodeResponse = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type CreateUsersWithArrayInputResult = CreateUsersWithArrayInputDefaultStatusCode of CreateUsersWithArrayInputDefaultStatusCodeResponse
|
||||
|
||||
type CreateUsersWithArrayInputArgs = {
|
||||
bodyParams:CreateUsersWithArrayInputBodyParams
|
||||
}
|
||||
|
||||
//#region Body parameters
|
||||
[<CLIMutable>]
|
||||
type CreateUsersWithListInputBodyParams = User[]
|
||||
//#endregion
|
||||
|
||||
|
||||
type CreateUsersWithListInputDefaultStatusCodeResponse = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type CreateUsersWithListInputResult = CreateUsersWithListInputDefaultStatusCode of CreateUsersWithListInputDefaultStatusCodeResponse
|
||||
|
||||
type CreateUsersWithListInputArgs = {
|
||||
bodyParams:CreateUsersWithListInputBodyParams
|
||||
}
|
||||
//#region Path parameters
|
||||
[<CLIMutable>]
|
||||
type DeleteUserPathParams = {
|
||||
username : string ;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
type DeleteUserStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
|
||||
type DeleteUserStatusCode404Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type DeleteUserResult = DeleteUserStatusCode400 of DeleteUserStatusCode400Response|DeleteUserStatusCode404 of DeleteUserStatusCode404Response
|
||||
|
||||
type DeleteUserArgs = {
|
||||
pathParams:DeleteUserPathParams;
|
||||
}
|
||||
//#region Path parameters
|
||||
[<CLIMutable>]
|
||||
type GetUserByNamePathParams = {
|
||||
username : string ;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
type GetUserByNameDefaultStatusCodeResponse = {
|
||||
content:User;
|
||||
|
||||
}
|
||||
|
||||
type GetUserByNameStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
|
||||
type GetUserByNameStatusCode404Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type GetUserByNameResult = GetUserByNameDefaultStatusCode of GetUserByNameDefaultStatusCodeResponse|GetUserByNameStatusCode400 of GetUserByNameStatusCode400Response|GetUserByNameStatusCode404 of GetUserByNameStatusCode404Response
|
||||
|
||||
type GetUserByNameArgs = {
|
||||
pathParams:GetUserByNamePathParams;
|
||||
}
|
||||
|
||||
//#region Query parameters
|
||||
[<CLIMutable>]
|
||||
type LoginUserQueryParams = {
|
||||
username : string ;
|
||||
|
||||
|
||||
password : string ;
|
||||
|
||||
}
|
||||
//#endregion
|
||||
|
||||
|
||||
type LoginUserDefaultStatusCodeResponse = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
|
||||
type LoginUserStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type LoginUserResult = LoginUserDefaultStatusCode of LoginUserDefaultStatusCodeResponse|LoginUserStatusCode400 of LoginUserStatusCode400Response
|
||||
|
||||
type LoginUserArgs = {
|
||||
queryParams:Result<LoginUserQueryParams,string>;
|
||||
}
|
||||
|
||||
|
||||
type LogoutUserDefaultStatusCodeResponse = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type LogoutUserResult = LogoutUserDefaultStatusCode of LogoutUserDefaultStatusCodeResponse
|
||||
|
||||
//#region Path parameters
|
||||
[<CLIMutable>]
|
||||
type UpdateUserPathParams = {
|
||||
username : string ;
|
||||
}
|
||||
//#endregion
|
||||
|
||||
//#region Body parameters
|
||||
[<CLIMutable>]
|
||||
type UpdateUserBodyParams = User
|
||||
//#endregion
|
||||
|
||||
|
||||
type UpdateUserStatusCode400Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
|
||||
type UpdateUserStatusCode404Response = {
|
||||
content:string;
|
||||
|
||||
}
|
||||
type UpdateUserResult = UpdateUserStatusCode400 of UpdateUserStatusCode400Response|UpdateUserStatusCode404 of UpdateUserStatusCode404Response
|
||||
|
||||
type UpdateUserArgs = {
|
||||
pathParams:UpdateUserPathParams;
|
||||
bodyParams:UpdateUserBodyParams
|
||||
}
|
||||
|
||||
@@ -0,0 +1,19 @@
|
||||
namespace OpenAPI
|
||||
open UserApiHandlerParams
|
||||
open System
|
||||
open Microsoft.AspNetCore.Http
|
||||
|
||||
|
||||
module UserApiServiceInterface =
|
||||
|
||||
//#region Service interface
|
||||
type IUserApiService =
|
||||
abstract member CreateUser : CreateUserBodyParams -> CreateUserResult
|
||||
abstract member CreateUsersWithArrayInput : CreateUsersWithArrayInputBodyParams -> CreateUsersWithArrayInputResult
|
||||
abstract member CreateUsersWithListInput : CreateUsersWithListInputBodyParams -> CreateUsersWithListInputResult
|
||||
abstract member DeleteUser : unit -> DeleteUserResult
|
||||
abstract member GetUserByName : unit -> GetUserByNameResult
|
||||
abstract member LoginUser : unit -> LoginUserResult
|
||||
abstract member LogoutUser : unit -> LogoutUserResult
|
||||
abstract member UpdateUser : UpdateUserBodyParams -> UpdateUserResult
|
||||
//#endregion
|
||||
@@ -0,0 +1,71 @@
|
||||
namespace OpenAPI
|
||||
open OpenAPI.Model.ApiResponse
|
||||
open OpenAPI.Model.Pet
|
||||
open PetApiHandlerParams
|
||||
open PetApiServiceInterface
|
||||
open System.Collections.Generic
|
||||
open System
|
||||
|
||||
module PetApiServiceImplementation =
|
||||
|
||||
//#region Service implementation
|
||||
type PetApiServiceImpl() =
|
||||
interface IPetApiService with
|
||||
|
||||
member this.AddPet (parameters:AddPetBodyParams) =
|
||||
let content = "Invalid input"
|
||||
AddPetStatusCode405 { content = content }
|
||||
|
||||
member this.DeletePet () =
|
||||
let content = "Invalid pet value"
|
||||
DeletePetStatusCode400 { content = content }
|
||||
|
||||
member this.FindPetsByStatus () =
|
||||
if true then
|
||||
let content = "successful operation" :> obj :?> Pet[] // this cast is obviously wrong, and is only intended to allow generated project to compile
|
||||
FindPetsByStatusDefaultStatusCode { content = content }
|
||||
else
|
||||
let content = "Invalid status value"
|
||||
FindPetsByStatusStatusCode400 { content = content }
|
||||
|
||||
member this.FindPetsByTags () =
|
||||
if true then
|
||||
let content = "successful operation" :> obj :?> Pet[] // this cast is obviously wrong, and is only intended to allow generated project to compile
|
||||
FindPetsByTagsDefaultStatusCode { content = content }
|
||||
else
|
||||
let content = "Invalid tag value"
|
||||
FindPetsByTagsStatusCode400 { content = content }
|
||||
|
||||
member this.GetPetById () =
|
||||
if true then
|
||||
let content = "successful operation" :> obj :?> Pet // this cast is obviously wrong, and is only intended to allow generated project to compile
|
||||
GetPetByIdDefaultStatusCode { content = content }
|
||||
else if true then
|
||||
let content = "Invalid ID supplied"
|
||||
GetPetByIdStatusCode400 { content = content }
|
||||
else
|
||||
let content = "Pet not found"
|
||||
GetPetByIdStatusCode404 { content = content }
|
||||
|
||||
member this.UpdatePet (parameters:UpdatePetBodyParams) =
|
||||
if true then
|
||||
let content = "Invalid ID supplied"
|
||||
UpdatePetStatusCode400 { content = content }
|
||||
else if true then
|
||||
let content = "Pet not found"
|
||||
UpdatePetStatusCode404 { content = content }
|
||||
else
|
||||
let content = "Validation exception"
|
||||
UpdatePetStatusCode405 { content = content }
|
||||
|
||||
member this.UpdatePetWithForm () =
|
||||
let content = "Invalid input"
|
||||
UpdatePetWithFormStatusCode405 { content = content }
|
||||
|
||||
member this.UploadFile () =
|
||||
let content = "successful operation" :> obj :?> ApiResponse // this cast is obviously wrong, and is only intended to allow generated project to compile
|
||||
UploadFileDefaultStatusCode { content = content }
|
||||
|
||||
//#endregion
|
||||
|
||||
let PetApiService = PetApiServiceImpl() :> IPetApiService
|
||||
@@ -0,0 +1,48 @@
|
||||
namespace OpenAPI
|
||||
open System.Collections.Generic
|
||||
open OpenAPI.Model.Order
|
||||
open StoreApiHandlerParams
|
||||
open StoreApiServiceInterface
|
||||
open System.Collections.Generic
|
||||
open System
|
||||
|
||||
module StoreApiServiceImplementation =
|
||||
|
||||
//#region Service implementation
|
||||
type StoreApiServiceImpl() =
|
||||
interface IStoreApiService with
|
||||
|
||||
member this.DeleteOrder () =
|
||||
if true then
|
||||
let content = "Invalid ID supplied"
|
||||
DeleteOrderStatusCode400 { content = content }
|
||||
else
|
||||
let content = "Order not found"
|
||||
DeleteOrderStatusCode404 { content = content }
|
||||
|
||||
member this.GetInventory () =
|
||||
let content = "successful operation" :> obj :?> IDictionary<string, int> // this cast is obviously wrong, and is only intended to allow generated project to compile
|
||||
GetInventoryDefaultStatusCode { content = content }
|
||||
|
||||
member this.GetOrderById () =
|
||||
if true then
|
||||
let content = "successful operation" :> obj :?> Order // this cast is obviously wrong, and is only intended to allow generated project to compile
|
||||
GetOrderByIdDefaultStatusCode { content = content }
|
||||
else if true then
|
||||
let content = "Invalid ID supplied"
|
||||
GetOrderByIdStatusCode400 { content = content }
|
||||
else
|
||||
let content = "Order not found"
|
||||
GetOrderByIdStatusCode404 { content = content }
|
||||
|
||||
member this.PlaceOrder (parameters:PlaceOrderBodyParams) =
|
||||
if true then
|
||||
let content = "successful operation" :> obj :?> Order // this cast is obviously wrong, and is only intended to allow generated project to compile
|
||||
PlaceOrderDefaultStatusCode { content = content }
|
||||
else
|
||||
let content = "Invalid Order"
|
||||
PlaceOrderStatusCode400 { content = content }
|
||||
|
||||
//#endregion
|
||||
|
||||
let StoreApiService = StoreApiServiceImpl() :> IStoreApiService
|
||||
@@ -0,0 +1,67 @@
|
||||
namespace OpenAPI
|
||||
open OpenAPI.Model.User
|
||||
open UserApiHandlerParams
|
||||
open UserApiServiceInterface
|
||||
open System.Collections.Generic
|
||||
open System
|
||||
|
||||
module UserApiServiceImplementation =
|
||||
|
||||
//#region Service implementation
|
||||
type UserApiServiceImpl() =
|
||||
interface IUserApiService with
|
||||
|
||||
member this.CreateUser (parameters:CreateUserBodyParams) =
|
||||
let content = "successful operation"
|
||||
CreateUserDefaultStatusCode { content = content }
|
||||
|
||||
member this.CreateUsersWithArrayInput (parameters:CreateUsersWithArrayInputBodyParams) =
|
||||
let content = "successful operation"
|
||||
CreateUsersWithArrayInputDefaultStatusCode { content = content }
|
||||
|
||||
member this.CreateUsersWithListInput (parameters:CreateUsersWithListInputBodyParams) =
|
||||
let content = "successful operation"
|
||||
CreateUsersWithListInputDefaultStatusCode { content = content }
|
||||
|
||||
member this.DeleteUser () =
|
||||
if true then
|
||||
let content = "Invalid username supplied"
|
||||
DeleteUserStatusCode400 { content = content }
|
||||
else
|
||||
let content = "User not found"
|
||||
DeleteUserStatusCode404 { content = content }
|
||||
|
||||
member this.GetUserByName () =
|
||||
if true then
|
||||
let content = "successful operation" :> obj :?> User // this cast is obviously wrong, and is only intended to allow generated project to compile
|
||||
GetUserByNameDefaultStatusCode { content = content }
|
||||
else if true then
|
||||
let content = "Invalid username supplied"
|
||||
GetUserByNameStatusCode400 { content = content }
|
||||
else
|
||||
let content = "User not found"
|
||||
GetUserByNameStatusCode404 { content = content }
|
||||
|
||||
member this.LoginUser () =
|
||||
if true then
|
||||
let content = "successful operation" :> obj :?> string // this cast is obviously wrong, and is only intended to allow generated project to compile
|
||||
LoginUserDefaultStatusCode { content = content }
|
||||
else
|
||||
let content = "Invalid username/password supplied"
|
||||
LoginUserStatusCode400 { content = content }
|
||||
|
||||
member this.LogoutUser () =
|
||||
let content = "successful operation"
|
||||
LogoutUserDefaultStatusCode { content = content }
|
||||
|
||||
member this.UpdateUser (parameters:UpdateUserBodyParams) =
|
||||
if true then
|
||||
let content = "Invalid user supplied"
|
||||
UpdateUserStatusCode400 { content = content }
|
||||
else
|
||||
let content = "User not found"
|
||||
UpdateUserStatusCode404 { content = content }
|
||||
|
||||
//#endregion
|
||||
|
||||
let UserApiService = UserApiServiceImpl() :> IUserApiService
|
||||
@@ -0,0 +1,22 @@
|
||||
namespace OpenAPI.Model
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open Newtonsoft.Json
|
||||
|
||||
module ApiResponse =
|
||||
|
||||
//#region ApiResponse
|
||||
|
||||
[<CLIMutable>]
|
||||
type ApiResponse = {
|
||||
[<JsonProperty(PropertyName = "code")>]
|
||||
Code : int;
|
||||
[<JsonProperty(PropertyName = "type")>]
|
||||
Type : string;
|
||||
[<JsonProperty(PropertyName = "message")>]
|
||||
Message : string;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace OpenAPI.Model
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open Newtonsoft.Json
|
||||
|
||||
module Category =
|
||||
|
||||
//#region Category
|
||||
|
||||
[<CLIMutable>]
|
||||
type Category = {
|
||||
[<JsonProperty(PropertyName = "id")>]
|
||||
Id : int64;
|
||||
[<JsonProperty(PropertyName = "name")>]
|
||||
Name : string;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
namespace OpenAPI.Model
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open Newtonsoft.Json
|
||||
|
||||
module Order =
|
||||
|
||||
//#region Order
|
||||
|
||||
[<CLIMutable>]
|
||||
type Order = {
|
||||
[<JsonProperty(PropertyName = "id")>]
|
||||
Id : int64;
|
||||
[<JsonProperty(PropertyName = "petId")>]
|
||||
PetId : int64;
|
||||
[<JsonProperty(PropertyName = "quantity")>]
|
||||
Quantity : int;
|
||||
[<JsonProperty(PropertyName = "shipDate")>]
|
||||
ShipDate : Nullable<DateTime>;
|
||||
[<JsonProperty(PropertyName = "status")>]
|
||||
Status : string;
|
||||
[<JsonProperty(PropertyName = "complete")>]
|
||||
Complete : bool;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
namespace OpenAPI.Model
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open Newtonsoft.Json
|
||||
open OpenAPI.Model.Category
|
||||
open OpenAPI.Model.Tag
|
||||
|
||||
module Pet =
|
||||
|
||||
//#region Pet
|
||||
|
||||
[<CLIMutable>]
|
||||
type Pet = {
|
||||
[<JsonProperty(PropertyName = "id")>]
|
||||
Id : int64;
|
||||
[<JsonProperty(PropertyName = "category")>]
|
||||
Category : Category;
|
||||
[<JsonProperty(PropertyName = "name")>]
|
||||
Name : string;
|
||||
[<JsonProperty(PropertyName = "photoUrls")>]
|
||||
PhotoUrls : string[];
|
||||
[<JsonProperty(PropertyName = "tags")>]
|
||||
Tags : Tag[];
|
||||
[<JsonProperty(PropertyName = "status")>]
|
||||
Status : string;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
namespace OpenAPI.Model
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open Newtonsoft.Json
|
||||
|
||||
module Tag =
|
||||
|
||||
//#region Tag
|
||||
|
||||
[<CLIMutable>]
|
||||
type Tag = {
|
||||
[<JsonProperty(PropertyName = "id")>]
|
||||
Id : int64;
|
||||
[<JsonProperty(PropertyName = "name")>]
|
||||
Name : string;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
namespace OpenAPI.Model
|
||||
|
||||
open System
|
||||
open System.Collections.Generic
|
||||
open Newtonsoft.Json
|
||||
|
||||
module User =
|
||||
|
||||
//#region User
|
||||
|
||||
[<CLIMutable>]
|
||||
type User = {
|
||||
[<JsonProperty(PropertyName = "id")>]
|
||||
Id : int64;
|
||||
[<JsonProperty(PropertyName = "username")>]
|
||||
Username : string;
|
||||
[<JsonProperty(PropertyName = "firstName")>]
|
||||
FirstName : string;
|
||||
[<JsonProperty(PropertyName = "lastName")>]
|
||||
LastName : string;
|
||||
[<JsonProperty(PropertyName = "email")>]
|
||||
Email : string;
|
||||
[<JsonProperty(PropertyName = "password")>]
|
||||
Password : string;
|
||||
[<JsonProperty(PropertyName = "phone")>]
|
||||
Phone : string;
|
||||
[<JsonProperty(PropertyName = "userStatus")>]
|
||||
UserStatus : int;
|
||||
}
|
||||
|
||||
//#endregion
|
||||
|
||||
Reference in New Issue
Block a user