Skip to content

Commit

Permalink
add test for enum support in operation param for python codegen
Browse files Browse the repository at this point in the history
  • Loading branch information
wkarwacki committed Nov 24, 2024
1 parent f223019 commit 47955e2
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lib/test/op-params-only-from-open-api-open-api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
paths:
/op0/path:
get:
parameters:
- in: query
name: optQueryParamEnumWithDefault
schema:
$ref: '#/components/schemas/SomeEnum'
default: second-val
operationId: op0Gett
components:
schemas:
SomeEnum:
type: string
enum:
- first-val
- second-val
15 changes: 15 additions & 0 deletions src/lib/test/op-params-only-from-open-api-trust.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ops:
/op0/path:
- name: op0Gett
params:
- loc: query
name: optQueryParamEnumWithDefault
path: defs.SomeEnum
default: second-val
type: GET
defs:
SomeEnum:
type: enum
vals:
- first-val
- second-val
12 changes: 12 additions & 0 deletions src/lib/test/op-params-open-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ paths:
schema:
type: boolean
default: true
- in: query
name: optQueryParamEnum
schema:
$ref: '#/components/schemas/SomeEnum'
required: true
operationId: op0Gett
post:
parameters:
Expand Down Expand Up @@ -74,3 +79,10 @@ paths:
schema:
type: string
required: true
components:
schemas:
SomeEnum:
type: string
enum:
- first-val
- second-val
9 changes: 9 additions & 0 deletions src/lib/test/op-params-trust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ ops:
loc: query
type: bool
default: true
- name: optQueryParamEnum
loc: query
path: defs.SomeEnum
type: GET
- name: op1Postt
params:
Expand Down Expand Up @@ -62,3 +65,9 @@ ops:
loc: query
type: str
type: POST
defs:
SomeEnum:
type: enum
vals:
- first-val
- second-val
10 changes: 10 additions & 0 deletions src/lib/test/op_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,21 @@ mod op_params {
from_open_api_test_fn("op-params");
}

#[test]
fn only_from_open_api_test() {
from_open_api_test_fn("op-params-only-from-open-api");
}

#[test]
fn gen_python_client_test() {
gen_test(Lang::Python, Role::Client, "op-params-trust.yml");
}

#[test]
fn gen_python_extended_client_test() {
gen_test(Lang::Python, Role::Client, "op-params-only-from-open-api-trust.yml");
}

#[test]
fn gen_python_server_test() {
gen_test(Lang::Python, Role::Server, "op-params-trust.yml");
Expand Down

0 comments on commit 47955e2

Please sign in to comment.