Skip to content

Commit c67c918

Browse files
author
James (ODSC)
authored
Merge pull request #372 from OpenDataServices/185-dep-fields
185 dep fields
2 parents 1edf755 + 8e0e6e9 commit c67c918

File tree

9 files changed

+54
-1
lines changed

9 files changed

+54
-1
lines changed

.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ examples/create-template/deprecated-yes/actual
1818
examples/create-template/deprecated-yes/actual.*
1919
examples/create-template/deprecated-no/actual
2020
examples/create-template/deprecated-no/actual.*
21+
examples/create-template/deprecated-yes-ref/actual
22+
examples/create-template/deprecated-yes-ref/actual.*
23+
examples/create-template/deprecated-no-ref/actual
24+
examples/create-template/deprecated-no-ref/actual.*
2125
examples/create-template/refs/actual
2226
examples/create-template/refs/actual.*
2327
examples/create-template/truncation-length/actual
@@ -50,4 +54,8 @@ examples/receipt/source-map/actual
5054
examples/receipt/source-map/actual.*
5155
examples/bods/unflatten/actual
5256
examples/bods/unflatten/actual.*
57+
examples/titles-ref/flatten/actual
58+
examples/titles-ref/flatten/actual.*
59+
examples/titles-ref/unflatten/actual
60+
examples/titles-ref/unflatten/actual.*
5361
.~lock*

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
99
### Fixed
1010

1111
- use-titles: Use $ref'erring title if available https://github.com/OpenDataServices/flatten-tool/pull/368
12+
- create-template --no-deprecated-fields: Did not work if deprecated element at same level as a $ref https://github.com/OpenDataServices/flatten-tool/issues/185#issuecomment-719587348
1213

1314
## [0.15.2] - 2020-10-29
1415

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ flatten-tool create-template --no-deprecated-fields --use-titles --main-sheet-name=interviewee --schema=examples/create-template/deprecated-ref.schema -f csv -o examples/create-template/deprecated-no-ref/actual
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Identifier,Name
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-04/schema#",
3+
"definitions": {
4+
"Pet": {
5+
"type": "object",
6+
"properties": {
7+
"name": {
8+
"type": "string",
9+
"title": "Pet name"
10+
}
11+
}
12+
}
13+
},
14+
"type": "object",
15+
"properties": {
16+
"id": {
17+
"type": "string",
18+
"title": "Identifier"
19+
},
20+
"name": {
21+
"type": "string",
22+
"title": "Name"
23+
},
24+
"pet": {
25+
"type": "string",
26+
"title": "Pet",
27+
"$ref": "#/definitions/Pet",
28+
"deprecated": {
29+
"description": "So yeah, H.R. told us that asking people in job interviews if they have pets is super illegal. Better stop that."
30+
}
31+
}
32+
}
33+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
$ flatten-tool create-template --use-titles --main-sheet-name=interviewee --schema=examples/create-template/deprecated-ref.schema -f csv -o examples/create-template/deprecated-yes-ref/actual
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Identifier,Name,Pet:Pet name

flattentool/schema.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,13 @@ def parse_schema_dict(
243243
):
244244
continue
245245

246+
if (
247+
self.exclude_deprecated_fields
248+
and hasattr(property_schema_dict, "__reference__")
249+
and property_schema_dict.__reference__.get("deprecated")
250+
):
251+
continue
252+
246253
property_type_set = get_property_type_set(property_schema_dict)
247254

248255
if (

flattentool/tests/test_docs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ def test_example_in_doc(root, filename):
133133

134134

135135
def test_expected_number_of_examples_in_docs_data():
136-
assert len(examples_in_docs_data) == 59
136+
assert len(examples_in_docs_data) == 61
137137

138138

139139
def _simplify_warnings(lines):

0 commit comments

Comments
 (0)