Skip to content

Commit 31868ca

Browse files
committed
test(gdscript): update integration tests
/spend 2h
1 parent c4fda71 commit 31868ca

File tree

23 files changed

+449
-360
lines changed

23 files changed

+449
-360
lines changed

bin/configs/gdscript-petstore.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ additionalProperties:
2626
# Timestamping the generated sample project would only add noise to git
2727
hideGenerationTimestamp: "true"
2828
# Since we're polluting the global namespace with class_name (it's really convenient),
29-
# we can use these prefixes to namespace the generated classes.
29+
# we can use these affixes to namespace the generated classes.
3030
# Best make sure the words you use here are not part of the domain of Godot.
31-
# It's a bit cumbersome to have to add all three (idea: globalNamePrefix as sugar?)
3231
apiNamePrefix: Demo
3332
modelNamePrefix: Demo
33+
modelNameSuffix: Model
3434
coreNamePrefix: Demo

modules/openapi-generator/src/main/resources/gdscript/core/ApiResponse.handlebars

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ extends {{>partials/api_response_parent_class}}
22
class_name {{>partials/api_response_class_name}}
33

44
# Headers sent back by the server
5-
@export var headers := Dictionary()
5+
var headers := Dictionary()
66

77
# Raw body of this response, in String form (before deserialization)
8-
@export var body := ""
8+
var body := ""
99

1010
# The HTTP response code, if any. A constant like HTTPClient.RESPONSE_XXXX
11-
@export var code := 0
11+
var code := 0
1212

1313
# Deserialized body (may be pretty much any type)
1414
var data

samples/client/petstore/gdscript/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ See https://github.com/OpenAPITools/openapi-generator/wiki/Integration-Tests
1919

2020
## Run
2121

22-
godot --headless --debug --path samples/client/petstore/gdscript --script addons/gut/gut_cmdln.gd
22+
godot --headless --debug --path samples/client/petstore/gdscript --script addons/gut/gut_cmdln.gd
2323

2424
The command should return a _zero_ exit code if all tests _passed_.
2525
You may want to add `--verbose` for more logs when debugging.

samples/client/petstore/gdscript/addons/oas.petstore.client/.openapi-generator/FILES

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ apis/DemoUserApi.md
88
core/DemoApiBee.gd
99
core/DemoApiConfig.gd
1010
core/DemoApiError.gd
11-
models/DemoApiResponse.gd
12-
models/DemoCategory.gd
13-
models/DemoOrder.gd
14-
models/DemoPet.gd
15-
models/DemoTag.gd
16-
models/DemoUser.gd
11+
core/DemoApiResponse.gd
12+
models/DemoApiResponseModel.gd
13+
models/DemoCategoryModel.gd
14+
models/DemoOrderModel.gd
15+
models/DemoPetModel.gd
16+
models/DemoTagModel.gd
17+
models/DemoUserModel.gd

samples/client/petstore/gdscript/addons/oas.petstore.client/README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
This is a sample server Petstore server. For this sample, you can use the api key `special-key` to test the authorization filters.
44

5-
This Godot 4 addon was automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
5+
This *Godot 4* addon was automatically generated by the [OpenAPI Generator](https://openapi-generator.tech) project:
66

77
− Servers:
88
- [http://petstore.swagger.io/v2](http://petstore.swagger.io/v2)
@@ -37,17 +37,18 @@ var api = DemoPetApi.new(config)
3737
# You can also provide your own HTTPClient, to re-use it across apis.
3838
#var api = DemoPetApi.new(config, client)
3939
40-
var demoPet = DemoPet.new()
41-
# … fill model demoPet with data
40+
var demoPetModel = DemoPetModel.new()
41+
# … fill model demoPetModel with data
4242
4343
# Invoke an endpoint
4444
api.add_pet(
45-
# demoPet: DemoPet
45+
# demoPetModel: DemoPetModel
4646
# Pet object that needs to be added to the store
47-
demoPet,
47+
demoPetModel,
4848
# On Success
49-
func(result): # result is DemoPet
50-
prints("Success!", "add_pet", result)
49+
func(response): # response is DemoApiResponse
50+
prints("Success!", "add_pet", response)
51+
assert(response.data is DemoPetModel)
5152
pass # do things, make stuff
5253
,
5354
# On Error
@@ -59,6 +60,15 @@ api.add_pet(
5960
```
6061

6162

63+
## Customization
64+
65+
You can [override the templates](https://openapi-generator.tech/docs/templating/).
66+
67+
> 1. Grab templates with `openapi-generator author template -g gdscript --library gdscript`
68+
> 2. Hack around
69+
> 3. Regenerate using `--template <dir>` to target your custom templates dir
70+
71+
6272
## Documentation for API Endpoints
6373

6474
All URIs are relative to *http://petstore.swagger.io/v2*
@@ -89,12 +99,12 @@ Class | Method | HTTP request | Description
8999

90100
## Documentation For Models
91101

92-
- [DemoApiResponse](models/DemoApiResponse.md)
93-
- [DemoCategory](models/DemoCategory.md)
94-
- [DemoOrder](models/DemoOrder.md)
95-
- [DemoPet](models/DemoPet.md)
96-
- [DemoTag](models/DemoTag.md)
97-
- [DemoUser](models/DemoUser.md)
102+
- [DemoApiResponseModel](models/DemoApiResponseModel.md)
103+
- [DemoCategoryModel](models/DemoCategoryModel.md)
104+
- [DemoOrderModel](models/DemoOrderModel.md)
105+
- [DemoPetModel](models/DemoPetModel.md)
106+
- [DemoTagModel](models/DemoTagModel.md)
107+
- [DemoUserModel](models/DemoUserModel.md)
98108

99109

100110
## Documentation For Authorization

0 commit comments

Comments
 (0)