Skip to content

Commit

Permalink
feat: Rename choices to choice_set for custom fields #2
Browse files Browse the repository at this point in the history
ref: 824cab7
  • Loading branch information
fbreckle committed Sep 13, 2023
1 parent 7d137c4 commit b56bba8
Show file tree
Hide file tree
Showing 5 changed files with 77 additions and 46 deletions.
40 changes: 29 additions & 11 deletions netbox/models/custom_field.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 29 additions & 11 deletions netbox/models/writable_custom_field.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions preprocess.py
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,17 @@
logging.info("Make ASN.rir a full RIR object")
data["definitions"]["ASN"]["properties"]["rir"] = {"$ref": "#/definitions/NestedRIR"}

# Change custom fields choices to ChoiceSet reference
logging.info("Change custom field choices to ChoiceSet ref")
del data["definitions"]["CustomField"]["properties"]["choices"]
data["definitions"]["CustomField"]["properties"]["choice_set"] = {
"$ref": "#/definitions/CustomFieldChoiceSet"
}
del data["definitions"]["WritableCustomField"]["properties"]["choices"]
data["definitions"]["WritableCustomField"]["properties"]["choice_set"] = {
"$ref": "#/definitions/CustomFieldChoiceSet"
}

# Write output file
with open("swagger.processed.json", "w") as writefile:
json.dump(data, writefile, indent=2)
Expand Down
4 changes: 2 additions & 2 deletions swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -82654,7 +82654,7 @@
"type": "string",
"maxLength": 500
},
"choice_set": {
"choices": {
"description": "Comma-separated list of available choices (for selection fields)",
"type": "array",
"items": {
Expand Down Expand Up @@ -82831,7 +82831,7 @@
"type": "string",
"maxLength": 500
},
"choice_set": {
"choices": {
"description": "Comma-separated list of available choices (for selection fields)",
"type": "array",
"items": {
Expand Down
28 changes: 6 additions & 22 deletions swagger.processed.json
Original file line number Diff line number Diff line change
Expand Up @@ -81648,17 +81648,6 @@
"type": "string",
"maxLength": 500
},
"choice_set": {
"description": "Comma-separated list of available choices (for selection fields)",
"type": "array",
"items": {
"title": "Choices",
"type": "string",
"maxLength": 100,
"minLength": 1
},
"x-nullable": true
},
"created": {
"title": "Created",
"type": "string",
Expand All @@ -81672,6 +81661,9 @@
"format": "date-time",
"readOnly": true,
"x-nullable": true
},
"choice_set": {
"$ref": "#/definitions/CustomFieldChoiceSet"
}
}
},
Expand Down Expand Up @@ -81826,17 +81818,6 @@
"type": "string",
"maxLength": 500
},
"choice_set": {
"description": "Comma-separated list of available choices (for selection fields)",
"type": "array",
"items": {
"title": "Choices",
"type": "string",
"maxLength": 100,
"minLength": 1
},
"x-nullable": true
},
"created": {
"title": "Created",
"type": "string",
Expand All @@ -81850,6 +81831,9 @@
"format": "date-time",
"readOnly": true,
"x-nullable": true
},
"choice_set": {
"$ref": "#/definitions/CustomFieldChoiceSet"
}
}
},
Expand Down

0 comments on commit b56bba8

Please sign in to comment.