Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
C
caosdb-advanced-user-tools
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
caosdb
Software
caosdb-advanced-user-tools
Commits
fb1f78d8
Verified
Commit
fb1f78d8
authored
1 year ago
by
Daniel Hornung
Browse files
Options
Downloads
Patches
Plain Diff
ENH: json schema exporter: Removed "ID, " from reference enums.
parent
ce21eb96
No related branches found
No related tags found
2 merge requests
!89
ENH: JsonSchemaExporter accepts do_not_create parameter.
,
!85
more jsonschema export
Pipeline
#43494
failed
1 year ago
Stage: setup
Stage: cert
Stage: style
Stage: unittest
Stage: integrationtest
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/caosadvancedtools/json_schema_exporter.py
+1
-1
1 addition, 1 deletion
src/caosadvancedtools/json_schema_exporter.py
unittests/test_json_schema_exporter.py
+18
-18
18 additions, 18 deletions
unittests/test_json_schema_exporter.py
with
19 additions
and
19 deletions
src/caosadvancedtools/json_schema_exporter.py
+
1
−
1
View file @
fb1f78d8
...
...
@@ -239,7 +239,7 @@ class JsonSchemaExporter:
vals
=
[]
for
val
in
possible_values
:
if
val
.
name
:
vals
.
append
(
f
"
{
val
.
id
}
,
{
val
.
name
}
"
)
vals
.
append
(
f
"
{
val
.
name
}
"
)
else
:
vals
.
append
(
f
"
{
val
.
id
}
"
)
...
...
This diff is collapsed.
Click to expand it.
unittests/test_json_schema_exporter.py
+
18
−
18
View file @
fb1f78d8
...
...
@@ -337,11 +337,11 @@ def test_rt_with_references():
assert
"
oneOf
"
not
in
props
[
"
RefProp
"
]
example
=
{
"
RefProp
"
:
"
101,
otherB
"
"
RefProp
"
:
"
otherB
"
}
validate
(
example
,
schema
)
example
=
{
"
RefProp
"
:
"
23,
I don
'
t exist
"
"
RefProp
"
:
"
I don
'
t exist
"
}
with
raises
(
ValidationError
):
# Wrong enum value
...
...
@@ -372,8 +372,8 @@ def test_rt_with_references():
assert
"
enum
"
in
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
]
assert
isinstance
(
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
],
list
)
assert
len
(
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
])
==
3
assert
"
100,
otherA
"
in
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
101,
otherB
"
in
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
otherA
"
in
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
otherB
"
in
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
102
"
in
props
[
"
RefProp
"
][
"
oneOf
"
][
enum_index
][
"
enum
"
]
# the other element of oneOf is the OtherType object
assert
props
[
"
RefProp
"
][
"
oneOf
"
][
1
-
enum_index
][
"
type
"
]
==
"
object
"
...
...
@@ -395,7 +395,7 @@ def test_rt_with_references():
validate
(
example
,
schema
)
example
=
{
"
RefProp
"
:
"
101,
otherB
"
,
"
RefProp
"
:
"
otherB
"
,
"
OtherTextProp
"
:
"
something
"
}
validate
(
example
,
schema
)
...
...
@@ -423,17 +423,17 @@ def test_rt_with_references():
assert
"
description
"
not
in
items
example
=
{
"
RefProp
"
:
"
101,
otherB
"
"
RefProp
"
:
"
otherB
"
}
with
raises
(
ValidationError
):
# Should be list but isn't
validate
(
example
,
schema
)
example
=
{
"
RefProp
"
:
[
"
101,
otherB
"
]
"
RefProp
"
:
[
"
otherB
"
]
}
validate
(
example
,
schema
)
example
=
{
"
RefProp
"
:
[
"
101,
otherB
"
,
"
102
"
,
"
104,
referencing
"
]
"
RefProp
"
:
[
"
otherB
"
,
"
102
"
,
"
referencing
"
]
}
validate
(
example
,
schema
)
...
...
@@ -461,8 +461,8 @@ def test_rt_with_references():
assert
"
enum
"
in
items
[
"
oneOf
"
][
enum_index
]
assert
isinstance
(
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
],
list
)
assert
len
(
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
])
==
3
assert
"
100,
otherA
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
101,
otherB
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
otherA
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
otherB
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
102
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
other_type
=
items
[
"
oneOf
"
][
1
-
enum_index
]
assert
other_type
[
"
type
"
]
==
"
object
"
...
...
@@ -472,7 +472,7 @@ def test_rt_with_references():
assert
"
IntegerProp
"
in
other_type
[
"
required
"
]
example
=
{
"
RefProp
"
:
[
"
101,
otherB
"
,
"
102
"
,
"
104,
referencing
"
]
"
RefProp
"
:
[
"
otherB
"
,
"
102
"
,
"
referencing
"
]
}
with
raises
(
ValidationError
):
# Wrong value in enum
...
...
@@ -488,7 +488,7 @@ def test_rt_with_references():
# we have additional_properties=False which propagates to subschemas
validate
(
example
,
schema
)
example
=
{
"
RefProp
"
:
[{
"
IntegerProp
"
:
12
},
"
101,
otherB
"
]
"
RefProp
"
:
[{
"
IntegerProp
"
:
12
},
"
otherB
"
]
}
validate
(
example
,
schema
)
...
...
@@ -506,7 +506,7 @@ def test_rt_with_references():
enum_index
=
1
-
enum_index
assert
len
(
ref_ref
[
"
oneOf
"
][
enum_index
][
"
enum
"
])
==
2
assert
"
103
"
in
ref_ref
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
104,
referencing
"
in
ref_ref
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
referencing
"
in
ref_ref
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
ref_ref
[
"
oneOf
"
][
1
-
enum_index
][
"
type
"
]
==
"
object
"
assert
"
OtherType
"
in
ref_ref
[
"
oneOf
"
][
1
-
enum_index
][
"
properties
"
]
assert
ref_ref
[
"
oneOf
"
][
1
-
enum_index
][
"
properties
"
][
"
OtherType
"
][
"
type
"
]
==
"
array
"
...
...
@@ -520,8 +520,8 @@ def test_rt_with_references():
assert
"
enum
"
in
items
[
"
oneOf
"
][
enum_index
]
assert
isinstance
(
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
],
list
)
assert
len
(
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
])
==
3
assert
"
100,
otherA
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
101,
otherB
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
otherA
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
otherB
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
assert
"
102
"
in
items
[
"
oneOf
"
][
enum_index
][
"
enum
"
]
other_type
=
items
[
"
oneOf
"
][
1
-
enum_index
]
assert
other_type
[
"
type
"
]
==
"
object
"
...
...
@@ -532,7 +532,7 @@ def test_rt_with_references():
example
=
{
"
RefRefProp
"
:
{
"
OtherType
"
:
[
"
100,
otherA
"
,
"
otherA
"
,
{
"
IntegerProp
"
:
12
}
]
}
...
...
@@ -638,7 +638,7 @@ RT2:
"
title
"
:
"
Existing entries
"
,
"
enum
"
: [
"
103
"
,
"
104,
referencing
"
"
referencing
"
]
},
{
...
...
@@ -684,7 +684,7 @@ RT2:
"
description
"
:
"
some description
"
,
"
enum
"
: [
"
103
"
,
"
104,
referencing
"
"
referencing
"
]
}
},
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment