Skip to content

Commit dabc7eb

Browse files
0.2.1 development
1 parent c1482f9 commit dabc7eb

18 files changed

+115
-110
lines changed

.coverage

0 Bytes
Binary file not shown.

.readthedocs.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ version: 2
99
build:
1010
os: ubuntu-22.04
1111
tools:
12-
python: "3.12"
12+
python: "3.13"
1313
# You can also specify other tool versions:
1414
# nodejs: "19"
1515
# rust: "1.64"

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# Will use this argument eventually to specify the python version so we can test against multiple versions
2-
ARG PYTHON=3.11
2+
ARG PYTHON=3.13
33
FROM python:${PYTHON}-slim-bookworm
44

55
ENV PATH="/root/.local/bin:$PATH" \

README.md

+27-26
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ interfaces:
4747
ipv4: "10.1.0.20/24"
4848
```
4949
50-
You can simply write out how you would like to document & validate this data in YAML using kinds, and this program will write out a JSON schema you can use.
50+
You can simply write out how you would like to document & validate this data in a YAML file, and this program will generate a JSON schema you can use.
5151
5252
```yaml
5353
header:
@@ -59,33 +59,33 @@ schema:
5959
type: "object"
6060
properties:
6161
hostname:
62-
kind: { name: "string" }
62+
js_kind: { name: "string" }
6363
model:
64-
kind: { name: "string" }
64+
js_kind: { name: "string" }
6565
device_type:
66-
kind: { name: "choice", choices: [ "router", "switch", "firewall", "load-balancer" ] }
66+
js_kind: { name: "choice", choices: [ "router", "switch", "firewall", "load-balancer" ] }
6767
system:
6868
type: "object"
6969
properties:
7070
domain_name:
71-
kind: { name: "string" }
71+
js_kind: { name: "string" }
7272
ntp_servers:
7373
type: "array"
7474
items:
75-
kind: { name: "ipv4" }
75+
js_kind: { name: "ipv4" }
7676
interfaces:
7777
type: "array"
7878
items:
7979
type: "object"
8080
properties:
8181
if:
82-
kind: { name: "string" }
82+
js_kind: { name: "string" }
8383
desc:
84-
kind: { name: "string" }
84+
js_kind: { name: "string" }
8585
ipv4:
86-
kind: { name: "ipv4_cidr" }
86+
js_kind: { name: "ipv4_cidr" }
8787
ipv6:
88-
kind: { name: "ipv6_cidr" }
88+
js_kind: { name: "ipv6_cidr" }
8989
```
9090
9191
```bash
@@ -112,7 +112,7 @@ Which language server you use is specific to your environment and editor that yo
112112
113113
## Detailed Example
114114
115-
We also have full support for writing your own titles, descriptions, kinds (sub-schemas), objects that are required, etc. A more fleshed out example of the same schema is below:
115+
We also have full support for writing your own titles, descriptions, js_kinds (sub-schemas), objects that are required, etc. A more fleshed out example of the same schema is below:
116116
117117
```yaml
118118
header:
@@ -124,7 +124,7 @@ header:
124124
- system
125125
- interfaces
126126
127-
kinds:
127+
js_kinds:
128128
hostname:
129129
title: "Hostname"
130130
description: "Hostname of the device"
@@ -142,15 +142,15 @@ schema:
142142
type: "object"
143143
properties:
144144
hostname:
145-
kind: { name: "hostname" }
145+
js_kind: { name: "hostname" }
146146
model:
147-
kind: { name: "string" }
147+
js_kind: { name: "string" }
148148
device_type:
149149
title: "Device Type"
150150
description: |
151151
Device Type options are:
152152
router, switch, firewall, load-balancer
153-
kind: { name: "choice", choices: [ "router", "switch", "firewall", "load-balancer" ] }
153+
js_kind: { name: "choice", choices: [ "router", "switch", "firewall", "load-balancer" ] }
154154
required: [ "hostname", "model", "device_type" ]
155155
system:
156156
title: "System"
@@ -161,13 +161,13 @@ schema:
161161
type: "object"
162162
properties:
163163
domain_name:
164-
kind: { name: "string" }
164+
js_kind: { name: "string" }
165165
ntp_servers:
166166
title: "NTP Servers"
167167
description: "List of NTP servers"
168168
type: "array"
169169
items:
170-
kind: { name: "ipv4" }
170+
js_kind: { name: "ipv4" }
171171
required: [ "domain_name", "ntp_servers" ]
172172
interfaces:
173173
title: "Device Interfaces"
@@ -182,17 +182,17 @@ schema:
182182
type: "object"
183183
properties:
184184
if:
185-
kind: { name: "string" }
185+
js_kind: { name: "string" }
186186
desc:
187-
kind: { name: "string" }
187+
js_kind: { name: "string" }
188188
ipv4:
189-
kind: { name: "ipv4_cidr" }
189+
js_kind: { name: "ipv4_cidr" }
190190
ipv6:
191-
kind: { name: "ipv6_cidr" }
191+
js_kind: { name: "ipv6_cidr" }
192192
required: [ "if" ]
193193
```
194194
195-
A full list of kinds are available in the [documentation](https://jsnac.readthedocs.io/en/latest/)
195+
A full list of js_kinds are available in the [documentation](https://jsnac.readthedocs.io/en/latest/)
196196
197197
## Usage
198198
@@ -215,14 +215,15 @@ jsnac -f data/example-jsnac.yml -v
215215
### Library
216216
```python
217217
"""
218-
This example demonstrates how to use the jsnac library to build a JSON schema from a YAML file in a Python script.
219-
Example yml file is available here: <https://www.github.com/commitconfirmed/jsnac/blob/main/data/example-jsnac.yml>
218+
This example demonstrates how to use the jsnac library to build a JSON schema
219+
from a YAML file in a Python script. An example YAML file is available below:
220+
<https://www.github.com/commitconfirmed/jsnac/blob/main/data/example-jsnac.yml>
220221
"""
221-
from jsnac.core.infer import SchemaInferer
222+
from jsnac.core.build import SchemaBuilder
222223

223224
def main():
224225
# Create a SchemaInferer object
225-
jsnac = SchemaInferer()
226+
jsnac = SchemaBuilder()
226227

227228
# Load the YAML data however you like into the SchemaInferer object
228229
with open('data/example-jsnac.yml', 'r') as file:

data/example-jsnac.json

+10-10
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"title": "Example Schema",
66
"description": "Ansible host vars for my networking device. Requires the below objects:\n- chassis\n- system\n- interfaces\n"
77
},
8-
"kinds": {
8+
"js_kinds": {
99
"hostname": {
1010
"title": "Hostname",
1111
"description": "Hostname of the device",
@@ -20,19 +20,19 @@
2020
"type": "object",
2121
"properties": {
2222
"hostname": {
23-
"kind": {
23+
"js_kind": {
2424
"name": "hostname"
2525
}
2626
},
2727
"model": {
28-
"kind": {
28+
"js_kind": {
2929
"name": "string"
3030
}
3131
},
3232
"device_type": {
3333
"title": "Device Type",
3434
"description": "Device Type options are:\nrouter, switch, firewall, load-balancer\n",
35-
"kind": {
35+
"js_kind": {
3636
"name": "choice",
3737
"choices": [
3838
"router",
@@ -55,7 +55,7 @@
5555
"type": "object",
5656
"properties": {
5757
"domain_name": {
58-
"kind": {
58+
"js_kind": {
5959
"name": "string"
6060
}
6161
},
@@ -64,7 +64,7 @@
6464
"description": "List of NTP servers",
6565
"type": "array",
6666
"items": {
67-
"kind": {
67+
"js_kind": {
6868
"name": "ipv4"
6969
}
7070
}
@@ -83,22 +83,22 @@
8383
"type": "object",
8484
"properties": {
8585
"if": {
86-
"kind": {
86+
"js_kind": {
8787
"name": "string"
8888
}
8989
},
9090
"desc": {
91-
"kind": {
91+
"js_kind": {
9292
"name": "string"
9393
}
9494
},
9595
"ipv4": {
96-
"kind": {
96+
"js_kind": {
9797
"name": "ipv4_cidr"
9898
}
9999
},
100100
"ipv6": {
101-
"kind": {
101+
"js_kind": {
102102
"name": "ipv6_cidr"
103103
}
104104
}

data/example-jsnac.yml

+10-10
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ header:
99
- system
1010
- interfaces
1111
12-
kinds:
12+
js_kinds:
1313
hostname:
1414
title: "Hostname"
1515
description: "Hostname of the device"
@@ -27,15 +27,15 @@ schema:
2727
type: "object"
2828
properties:
2929
hostname:
30-
kind: { name: "hostname" }
30+
js_kind: { name: "hostname" }
3131
model:
32-
kind: { name: "string" }
32+
js_kind: { name: "string" }
3333
device_type:
3434
title: "Device Type"
3535
description: |
3636
Device Type options are:
3737
router, switch, firewall, load-balancer
38-
kind: { name: "choice", choices: [ "router", "switch", "firewall", "load-balancer" ] }
38+
js_kind: { name: "choice", choices: [ "router", "switch", "firewall", "load-balancer" ] }
3939
required: [ "hostname", "model", "device_type" ]
4040
system:
4141
title: "System"
@@ -46,13 +46,13 @@ schema:
4646
type: "object"
4747
properties:
4848
domain_name:
49-
kind: { name: "string" }
49+
js_kind: { name: "string" }
5050
ntp_servers:
5151
title: "NTP Servers"
5252
description: "List of NTP servers"
5353
type: "array"
5454
items:
55-
kind: { name: "ipv4" }
55+
js_kind: { name: "ipv4" }
5656
required: [ "domain_name", "ntp_servers" ]
5757
interfaces:
5858
title: "Device Interfaces"
@@ -67,11 +67,11 @@ schema:
6767
type: "object"
6868
properties:
6969
if:
70-
kind: { name: "string" }
70+
js_kind: { name: "string" }
7171
desc:
72-
kind: { name: "string" }
72+
js_kind: { name: "string" }
7373
ipv4:
74-
kind: { name: "ipv4_cidr" }
74+
js_kind: { name: "ipv4_cidr" }
7575
ipv6:
76-
kind: { name: "ipv6_cidr" }
76+
js_kind: { name: "ipv6_cidr" }
7777
required: [ "if" ]

data/regenerate_test_data.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525

2626
import yaml
2727

28-
from jsnac.core.infer import SchemaInferer
28+
from jsnac.core.build import SchemaBuilder
2929

3030

3131
def write_json(file: str) -> None: # noqa: D103
@@ -55,7 +55,7 @@ def main() -> None: # noqa: D103
5555
write_json(example_jsnac_file)
5656
# Generate a schema for example-jsnac.yml
5757
with example_jsnac_file.open() as f:
58-
jsnac = SchemaInferer()
58+
jsnac = SchemaBuilder()
5959
jsnac.add_yaml(f.read())
6060
schema = jsnac.build_schema()
6161
f.close()

dist/jsnac-0.2.1-py3-none-any.whl

10.9 KB
Binary file not shown.

dist/jsnac-0.2.1.tar.gz

12.7 KB
Binary file not shown.

docs/source/examples.rst

+5-4
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,15 @@ Library usage:
2727
.. code-block:: python
2828
2929
"""
30-
This example demonstrates how to use the jsnac library to build a JSON schema from a YAML file in a Python script.
31-
Example yml file is available here: <https://www.github.com/commitconfirmed/jsnac/blob/main/data/example-jsnac.yml>
30+
This example demonstrates how to use the jsnac library to build a JSON schema
31+
from a YAML file in a Python script. An example YAML file is available below:
32+
<https://www.github.com/commitconfirmed/jsnac/blob/main/data/example-jsnac.yml>
3233
"""
33-
from jsnac.core.infer import SchemaInferer
34+
from jsnac.core.build import SchemaBuilder
3435
3536
def main():
3637
# Create a SchemaInferer object
37-
jsnac = SchemaInferer()
38+
jsnac = SchemaBuilder()
3839
3940
# Load the YAML data however you like into the SchemaInferer object
4041
with open('data/example-jsnac.yml', 'r') as file:

0 commit comments

Comments
 (0)