Skip to content

Commit c92fc49

Browse files
committed
add petstore v3 server impl
1 parent b5a2ddd commit c92fc49

20 files changed

+2705
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# OpenAPI Generator Ignore
2+
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
README.md
2+
src/PetStoreServer.jl
3+
src/api_PetApi.jl
4+
src/api_StoreApi.jl
5+
src/api_UserApi.jl
6+
src/model_ApiResponse.jl
7+
src/model_Category.jl
8+
src/model_Order.jl
9+
src/model_Pet.jl
10+
src/model_Tag.jl
11+
src/model_User.jl
12+
src/modelincludes.jl
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
6.1.0-SNAPSHOT
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Julia API server for PetStoreServer
2+
3+
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters. For OAuth2 flow, you may use `user` as both username and password when asked to login.
4+
5+
## Overview
6+
This API server was generated by the [OpenAPI Generator](https://openapi-generator.tech) project. By using the [openapi-spec](https://openapis.org) from a remote server, you can easily generate an API client.
7+
8+
- API version: 1.0.0
9+
- Package version:
10+
- Build package: org.openapitools.codegen.languages.JuliaServerCodegen
11+
12+
13+
## Installation
14+
Place the Julia files generated under the `src` folder in your Julia project. Include PetStoreServer.jl in the project code.
15+
It would include the module named PetStoreServer.
16+
17+
Implement the server methods. The expected methods are documented with the PetStoreServer module.
18+
Launch a HTTP server with a router that has all handlers registered. E.g.:
19+
20+
```
21+
router = PetStoreServer.register(HTTP.Router(), @__MODULE__)
22+
HTTP.serve(router, 8080) # start server on port 8080
23+
```
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
# This file was generated by the Julia OpenAPI Code Generator
2+
# Do not modify this file directly. Modify the OpenAPI specification instead.
3+
4+
5+
@doc raw"""
6+
Encapsulates generated server code for PetStoreServer
7+
8+
The following server methods must be implemented:
9+
10+
- **addPet**
11+
- *invocation:* POST /pet
12+
- *signature:* addPet(req::HTTP.Request, in\_Pet::Pet;) -> Nothing
13+
- **deletePet**
14+
- *invocation:* DELETE /pet/{petId}
15+
- *signature:* deletePet(req::HTTP.Request, in\_petId::Int64; in\_api_key=nothing,) -> Nothing
16+
- **findPetsByStatus**
17+
- *invocation:* GET /pet/findByStatus
18+
- *signature:* findPetsByStatus(req::HTTP.Request, in\_status::Vector{String};) -> Vector{Pet}
19+
- **findPetsByTags**
20+
- *invocation:* GET /pet/findByTags
21+
- *signature:* findPetsByTags(req::HTTP.Request, in\_tags::Vector{String};) -> Vector{Pet}
22+
- **getPetById**
23+
- *invocation:* GET /pet/{petId}
24+
- *signature:* getPetById(req::HTTP.Request, in\_petId::Int64;) -> Pet
25+
- **updatePet**
26+
- *invocation:* PUT /pet
27+
- *signature:* updatePet(req::HTTP.Request, in\_Pet::Pet;) -> Nothing
28+
- **updatePetWithForm**
29+
- *invocation:* POST /pet/{petId}
30+
- *signature:* updatePetWithForm(req::HTTP.Request, in\_petId::Int64; in\_name=nothing, in\_status=nothing,) -> Nothing
31+
- **uploadFile**
32+
- *invocation:* POST /pet/{petId}/uploadImage
33+
- *signature:* uploadFile(req::HTTP.Request, in\_petId::Int64; in\_additionalMetadata=nothing, in\_file=nothing,) -> ApiResponse
34+
- **deleteOrder**
35+
- *invocation:* DELETE /store/order/{orderId}
36+
- *signature:* deleteOrder(req::HTTP.Request, in\_orderId::String;) -> Nothing
37+
- **getInventory**
38+
- *invocation:* GET /store/inventory
39+
- *signature:* getInventory(req::HTTP.Request;) -> Dict{String, Int64}
40+
- **getOrderById**
41+
- *invocation:* GET /store/order/{orderId}
42+
- *signature:* getOrderById(req::HTTP.Request, in\_orderId::Int64;) -> Order
43+
- **placeOrder**
44+
- *invocation:* POST /store/order
45+
- *signature:* placeOrder(req::HTTP.Request, in\_Order::Order;) -> Order
46+
- **createUser**
47+
- *invocation:* POST /user
48+
- *signature:* createUser(req::HTTP.Request, in\_User::User;) -> Nothing
49+
- **createUsersWithArrayInput**
50+
- *invocation:* POST /user/createWithArray
51+
- *signature:* createUsersWithArrayInput(req::HTTP.Request, in\_User::Vector{User};) -> Nothing
52+
- **createUsersWithListInput**
53+
- *invocation:* POST /user/createWithList
54+
- *signature:* createUsersWithListInput(req::HTTP.Request, in\_User::Vector{User};) -> Nothing
55+
- **deleteUser**
56+
- *invocation:* DELETE /user/{username}
57+
- *signature:* deleteUser(req::HTTP.Request, in\_username::String;) -> Nothing
58+
- **getUserByName**
59+
- *invocation:* GET /user/{username}
60+
- *signature:* getUserByName(req::HTTP.Request, in\_username::String;) -> User
61+
- **loginUser**
62+
- *invocation:* GET /user/login
63+
- *signature:* loginUser(req::HTTP.Request, in\_username::String, in\_password::String;) -> String
64+
- **logoutUser**
65+
- *invocation:* GET /user/logout
66+
- *signature:* logoutUser(req::HTTP.Request;) -> Nothing
67+
- **updateUser**
68+
- *invocation:* PUT /user/{username}
69+
- *signature:* updateUser(req::HTTP.Request, in\_username::String, in\_User::User;) -> Nothing
70+
"""
71+
module PetStoreServer
72+
73+
using HTTP
74+
using URIs
75+
using Dates
76+
using Random
77+
using TimeZones
78+
using OpenAPI
79+
using OpenAPI.Servers
80+
81+
include("modelincludes.jl")
82+
83+
include("api_PetApi.jl")
84+
include("api_StoreApi.jl")
85+
include("api_UserApi.jl")
86+
87+
"""
88+
Register handlers for all APIs in this module in the supplier Router.
89+
90+
Paramerets:
91+
- `router`: Router to register handlers in
92+
- `impl`: module that implements the server methods
93+
94+
Optional parameters:
95+
- `path_prefix`: prefix to be applied to all paths
96+
- `optional_middlewares`: Register one or more optional middlewares to be applied to all requests.
97+
98+
Optional middlewares can be one or more of:
99+
- `init`: called before the request is processed
100+
- `pre_validation`: called after the request is parsed but before validation
101+
- `pre_invoke`: called after validation but before the handler is invoked
102+
- `post_invoke`: called after the handler is invoked but before the response is sent
103+
104+
The order in which middlewares are invoked are:
105+
`init |> read |> pre_validation |> validate |> pre_invoke |> invoke |> post_invoke`
106+
"""
107+
function register(router::HTTP.Router, impl; path_prefix::String="", optional_middlewares...)
108+
registerPetApi(router, impl; path_prefix=path_prefix, optional_middlewares...)
109+
registerStoreApi(router, impl; path_prefix=path_prefix, optional_middlewares...)
110+
registerUserApi(router, impl; path_prefix=path_prefix, optional_middlewares...)
111+
return router
112+
end
113+
114+
export check_required
115+
116+
# export models
117+
export ApiResponse
118+
export Category
119+
export Order
120+
export Pet
121+
export Tag
122+
export User
123+
124+
125+
end # module PetStoreServer

0 commit comments

Comments
 (0)