Skip to content

Commit 548abe5

Browse files
authored
adding some model generation tests (#38)
Adding some model generation tests corresponding to openapi-generator changes done in OpenAPITools/openapi-generator#16030
1 parent 0a4fc46 commit 548abe5

24 files changed

+607
-1
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: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
README.md
2+
docs/DefaultApi.md
3+
docs/TestModel.md
4+
src/ModelGenClient.jl
5+
src/apis/api_DefaultApi.jl
6+
src/modelincludes.jl
7+
src/models/model_TestModel.jl
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
7.0.0-SNAPSHOT
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Julia API client for ModelGenClient
2+
3+
Model Generation Tests
4+
5+
## Overview
6+
This API client 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: 0.1.0
9+
- Build package: org.openapitools.codegen.languages.JuliaClientCodegen
10+
11+
12+
## Installation
13+
Place the Julia files generated under the `src` folder in your Julia project. Include ModelGenClient.jl in the project code.
14+
It would include the module named ModelGenClient.
15+
16+
Documentation is generated as markdown files under the `docs` folder. You can include them in your project documentation.
17+
Documentation is also embedded in Julia which can be used with a Julia specific documentation generator.
18+
19+
## API Endpoints
20+
21+
Class | Method
22+
------------ | -------------
23+
*DefaultApi* | [**test**](docs/DefaultApi.md#test)<br/>**GET** /test<br/>Test
24+
25+
26+
## Models
27+
28+
- [TestModel](docs/TestModel.md)
29+
30+
31+
<a id="authorization"></a>
32+
## Authorization
33+
Endpoints do not require authorization.
34+
35+
36+
## Author
37+
38+
39+
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# DefaultApi
2+
3+
All URIs are relative to *http://localhost*
4+
5+
Method | HTTP request | Description
6+
------------- | ------------- | -------------
7+
[**test**](DefaultApi.md#test) | **GET** /test | Test
8+
9+
10+
# **test**
11+
> test(_api::DefaultApi; _mediaType=nothing) -> TestModel, OpenAPI.Clients.ApiResponse <br/>
12+
> test(_api::DefaultApi, response_stream::Channel; _mediaType=nothing) -> Channel{ TestModel }, OpenAPI.Clients.ApiResponse
13+
14+
Test
15+
16+
### Required Parameters
17+
This endpoint does not need any parameter.
18+
19+
### Return type
20+
21+
[**TestModel**](TestModel.md)
22+
23+
### Authorization
24+
25+
No authorization required
26+
27+
### HTTP request headers
28+
29+
- **Content-Type**: Not defined
30+
- **Accept**: application/json
31+
32+
[[Back to top]](#) [[Back to API list]](../README.md#api-endpoints) [[Back to Model list]](../README.md#models) [[Back to README]](../README.md)
33+
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# TestModel
2+
3+
4+
## Properties
5+
Name | Type | Description | Notes
6+
------------ | ------------- | ------------- | -------------
7+
**limited_by** | **String** | | [optional] [default to "time"]
8+
**default_date** | **Date** | | [optional] [default to OpenAPI.str2date("2011-11-11")]
9+
**default_datetime** | **ZonedDateTime** | | [optional] [default to OpenAPI.str2zoneddatetime("2011-11-11T11:11:11Z")]
10+
**max_val** | **Int64** | | [optional] [default to 100]
11+
12+
13+
[[Back to Model list]](../README.md#models) [[Back to API list]](../README.md#api-endpoints) [[Back to README]](../README.md)
14+
15+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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+
module ModelGenClient
5+
6+
using Dates, TimeZones
7+
using OpenAPI
8+
using OpenAPI.Clients
9+
10+
const API_VERSION = "0.1.0"
11+
12+
include("modelincludes.jl")
13+
14+
include("apis/api_DefaultApi.jl")
15+
16+
end # module ModelGenClient
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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+
struct DefaultApi <: OpenAPI.APIClientImpl
5+
client::OpenAPI.Clients.Client
6+
end
7+
8+
"""
9+
The default API base path for APIs in `DefaultApi`.
10+
This can be used to construct the `OpenAPI.Clients.Client` instance.
11+
"""
12+
basepath(::Type{ DefaultApi }) = "http://localhost"
13+
14+
const _returntypes_test_DefaultApi = Dict{Regex,Type}(
15+
Regex("^" * replace("200", "x"=>".") * "\$") => TestModel,
16+
)
17+
18+
function _oacinternal_test(_api::DefaultApi; _mediaType=nothing)
19+
_ctx = OpenAPI.Clients.Ctx(_api.client, "GET", _returntypes_test_DefaultApi, "/test", [])
20+
OpenAPI.Clients.set_header_accept(_ctx, ["application/json", ])
21+
OpenAPI.Clients.set_header_content_type(_ctx, (_mediaType === nothing) ? [] : [_mediaType])
22+
return _ctx
23+
end
24+
25+
@doc raw"""Test
26+
27+
Params:
28+
29+
Return: TestModel, OpenAPI.Clients.ApiResponse
30+
"""
31+
function test(_api::DefaultApi; _mediaType=nothing)
32+
_ctx = _oacinternal_test(_api; _mediaType=_mediaType)
33+
return OpenAPI.Clients.exec(_ctx)
34+
end
35+
36+
function test(_api::DefaultApi, response_stream::Channel; _mediaType=nothing)
37+
_ctx = _oacinternal_test(_api; _mediaType=_mediaType)
38+
return OpenAPI.Clients.exec(_ctx, response_stream)
39+
end
40+
41+
export test
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
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+
include("models/model_TestModel.jl")
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
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"""TestModel
6+
7+
TestModel(;
8+
limited_by="time",
9+
default_date=OpenAPI.str2date("2011-11-11"),
10+
default_datetime=OpenAPI.str2zoneddatetime("2011-11-11T11:11:11Z"),
11+
max_val=100,
12+
)
13+
14+
- limited_by::String
15+
- default_date::Date
16+
- default_datetime::ZonedDateTime
17+
- max_val::Int64
18+
"""
19+
Base.@kwdef mutable struct TestModel <: OpenAPI.APIModel
20+
limited_by::Union{Nothing, String} = "time"
21+
default_date::Union{Nothing, Date} = OpenAPI.str2date("2011-11-11")
22+
default_datetime::Union{Nothing, ZonedDateTime} = OpenAPI.str2zoneddatetime("2011-11-11T11:11:11Z")
23+
max_val::Union{Nothing, Int64} = 100
24+
25+
function TestModel(limited_by, default_date, default_datetime, max_val, )
26+
OpenAPI.validate_property(TestModel, Symbol("limited_by"), limited_by)
27+
OpenAPI.validate_property(TestModel, Symbol("default_date"), default_date)
28+
OpenAPI.validate_property(TestModel, Symbol("default_datetime"), default_datetime)
29+
OpenAPI.validate_property(TestModel, Symbol("max_val"), max_val)
30+
return new(limited_by, default_date, default_datetime, max_val, )
31+
end
32+
end # type TestModel
33+
34+
const _property_types_TestModel = Dict{Symbol,String}(Symbol("limited_by")=>"String", Symbol("default_date")=>"Date", Symbol("default_datetime")=>"ZonedDateTime", Symbol("max_val")=>"Int64", )
35+
OpenAPI.property_type(::Type{ TestModel }, name::Symbol) = Union{Nothing,eval(Base.Meta.parse(_property_types_TestModel[name]))}
36+
37+
function check_required(o::TestModel)
38+
true
39+
end
40+
41+
function OpenAPI.validate_property(::Type{ TestModel }, name::Symbol, val)
42+
if name === Symbol("limited_by")
43+
OpenAPI.validate_param(name, "TestModel", :enum, val, ["time", "cost", "unlimited"])
44+
end
45+
if name === Symbol("default_date")
46+
OpenAPI.validate_param(name, "TestModel", :format, val, "date")
47+
end
48+
if name === Symbol("default_datetime")
49+
OpenAPI.validate_param(name, "TestModel", :format, val, "date-time")
50+
end
51+
if name === Symbol("max_val")
52+
OpenAPI.validate_param(name, "TestModel", :enum, val, [100, 200, 300])
53+
end
54+
end

0 commit comments

Comments
 (0)