You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+63-38Lines changed: 63 additions & 38 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -9,14 +9,55 @@ The goal of OpenAPI is to define a standard, language-agnostic interface to REST
9
9
10
10
Check out [OpenAPI-Spec](https://github.com/OAI/OpenAPI-Specification) for additional information about the OpenAPI project, including additional libraries with support for other languages and more.
11
11
12
-
## How do I use this?
13
-
14
-
### Code Generation
12
+
## Code Generation
15
13
16
14
Use [instructions](https://openapi-generator.tech/docs/generators) provided for the Julia OpenAPI code generator plugin to generate Julia code.
17
15
18
16
## Generated Code Structure
19
17
18
+
### Models
19
+
20
+
Each model from the specification is generated into a file named `model_<modelname>.jl`. It is represented as a `mutable struct` that is a subtype of the abstract type `APIModel`. Models have the following methods defined:
21
+
22
+
- constructor that takes keyword arguments to fill in values for all model properties.
In addition to these standard Julia methods, these convenience methods are also generated that help in checking value at a hierarchical path of the model.
29
+
30
+
-`function haspropertyat(o::T, path...) where {T<:APIModel}`
31
+
-`function getpropertyat(o::T, path...) where {T<:APIModel}`
Following validations are incorporated into models:
50
+
51
+
- maximum value: must be a numeric value less than or equal to a specified value
52
+
- minimum value: must be a numeric value greater than or equal to a specified value
53
+
- maximum length: must be a string value of length less than or equal to a specified value
54
+
- minimum length: must be a string value of length greater than or equal to a specified value
55
+
- maximum item count: must be a list value with number of items less than or equal to a specified value
56
+
- minimum item count: must be a list value with number of items greater than or equal to a specified value
57
+
- enum: value must be from a list of allowed values
58
+
59
+
Validations are imposed in the constructor and `setproperty!` methods of models.
60
+
20
61
### Client APIs
21
62
22
63
Each client API set is generated into a file named `api_<apiname>.jl`. It is represented as a `struct` and the APIs under it are generated as methods. An API set can be constructed by providing the OpenAPI client instance that it can use for communication.
@@ -78,45 +119,29 @@ An API call involves the following steps:
78
119
- Convert (deserialize) the response data into the return type and return.
79
120
- In case of any errors, throw an instance of `ApiException`
80
121
81
-
### Models
122
+
##Server APIs
82
123
83
-
Each model from the specification is generated into a file named `model_<modelname>.jl`. It is represented as a `mutable struct` that is a subtype of the abstract type `APIModel`. Models have the following methods defined:
124
+
The server code is generated as a package. It contains API stubs and validations of API inputs. It requires the caller to
125
+
have implemented the APIs, the signatures of which are provided in the generated package module docstring.
84
126
85
-
- constructor that takes keyword arguments to fill in values for all model properties.
A `register` function is made available that when provided with a `Router` instance, registers handlers
128
+
for all the APIs.
90
129
91
-
In addition to these standard Julia methods, these convenience methods are also generated that help in checking value at a hierarchical path of the model.
0 commit comments