Skip to content

Commit 303d602

Browse files
authored
Add schema.ignores option to allow excluding attributes from mapping (#87)
* add edgecase * add gist (not working without ignores) * fix with ignores * add more ignores * add edgecase ignores * add config definition * add data source + element type ignores * add to provider schema * add resource and provider implementations * remove todos * add config test entries * add parse validation and tests * add tests for ignores * add tests for schema methods * add changelog
1 parent c7c68bf commit 303d602

25 files changed

+2140
-74
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
kind: FEATURES
2+
body: Added schema.ignores option to generator config for resources, data sources,
3+
and providers. Allows excluding attributes from OAS mapping
4+
time: 2023-10-26T16:20:53.404821-04:00
5+
custom:
6+
Issue: "81"

internal/cmd/testdata/edgecase/generator_config.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
provider:
22
name: edgecase
33
schema_ref: '#/components/schemas/edgecase_provider'
4+
ignores:
5+
- triple_nested_map.ignore_me_1
6+
- triple_nested_map.obj_prop.ignore_me_2
47

58
resources:
69
set_test:
@@ -10,6 +13,10 @@ resources:
1013
read:
1114
path: /set_test
1215
method: GET
16+
schema:
17+
ignores:
18+
- setnested_prop.string_prop
19+
1320
map_test:
1421
create:
1522
path: /map_test
@@ -23,6 +30,11 @@ data_sources:
2330
read:
2431
path: /nested_collections
2532
method: GET
33+
schema:
34+
ignores:
35+
- triple_nested_map.ignore_me_1
36+
- triple_nested_map.obj_prop.ignore_me_2
37+
2638
set_test:
2739
read:
2840
path: /set_test

internal/cmd/testdata/edgecase/openapi_spec.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -175,6 +175,19 @@ components:
175175
bool_prop:
176176
description: Bool inside a map!
177177
type: boolean
178+
ignore_me_1:
179+
description: This property will be ignored!
180+
type: string
181+
obj_prop:
182+
description: Object inside a map!
183+
type: object
184+
properties:
185+
number_prop:
186+
description: Number inside a map!
187+
type: number
188+
ignore_me_2:
189+
description: This property will be ignored!
190+
type: string
178191
setnested_schema:
179192
description: This is a set with a nested object
180193
type: array

internal/cmd/testdata/edgecase/provider_code_spec.json

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,17 @@
103103
"name": "bool_prop",
104104
"bool": {}
105105
},
106+
{
107+
"name": "obj_prop",
108+
"object": {
109+
"attribute_types": [
110+
{
111+
"name": "number_prop",
112+
"number": {}
113+
}
114+
]
115+
}
116+
},
106117
{
107118
"name": "string_prop",
108119
"string": {}
@@ -225,6 +236,17 @@
225236
"name": "bool_prop",
226237
"bool": {}
227238
},
239+
{
240+
"name": "obj_prop",
241+
"object": {
242+
"attribute_types": [
243+
{
244+
"name": "number_prop",
245+
"number": {}
246+
}
247+
]
248+
}
249+
},
228250
{
229251
"name": "string_prop",
230252
"string": {}
@@ -311,13 +333,6 @@
311333
"computed_optional_required": "computed_optional",
312334
"description": "Bool inside a set!"
313335
}
314-
},
315-
{
316-
"name": "string_prop",
317-
"string": {
318-
"computed_optional_required": "computed_optional",
319-
"description": "String inside a set!"
320-
}
321336
}
322337
]
323338
},

internal/cmd/testdata/github/generator_config.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,17 @@ resources:
2323
repo: name
2424

2525
data_sources:
26+
gists:
27+
read:
28+
path: /gists/{gist_id}
29+
method: GET
30+
schema:
31+
ignores:
32+
- fork_of.forks
33+
- fork_of.history
34+
- fork_of.files.language
35+
- forks.user.plan.collaborators
36+
2637
repository:
2738
read:
2839
path: /repos/{owner}/{repo}

0 commit comments

Comments
 (0)