Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Communications Backbone System
backbone-message-format
Commits
806f47dc
Commit
806f47dc
authored
2 years ago
by
Trishna Saeharaseelan
Browse files
Options
Download
Email Patches
Plain Diff
refactor(specs): revert definitions back to components/schemas
parent
231dca1e
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
37 additions
and
34 deletions
+37
-34
formats/acknowledgement.py
formats/acknowledgement.py
+1
-1
formats/mission_plan.py
formats/mission_plan.py
+1
-1
formats/observation.py
formats/observation.py
+1
-1
formats/planning_configuration.py
formats/planning_configuration.py
+1
-1
formats/platform_status.py
formats/platform_status.py
+1
-1
generate_swagger.py
generate_swagger.py
+32
-29
No files found.
formats/acknowledgement.py
View file @
806f47dc
...
...
@@ -7,7 +7,7 @@
acknowledgement_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/
definition
s/Message"
}],
"allOf"
:
[{
"$ref"
:
"#/
components/schema
s/Message"
}],
"type"
:
"object"
,
"properties"
:
{
"acknowledged_message_ID"
:
{
...
...
This diff is collapsed.
Click to expand it.
formats/mission_plan.py
View file @
806f47dc
...
...
@@ -63,7 +63,7 @@ action_schema = {
}
mission_plan_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/
definition
s/Message"
}],
"allOf"
:
[{
"$ref"
:
"#/
components/schema
s/Message"
}],
"type"
:
"object"
,
"properties"
:
{
"autonomy_engine_plan_ID"
:
{
...
...
This diff is collapsed.
Click to expand it.
formats/observation.py
View file @
806f47dc
...
...
@@ -30,7 +30,7 @@ hits_schema = {
}
observation_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/
definition
s/Message"
}],
"allOf"
:
[{
"$ref"
:
"#/
components/schema
s/Message"
}],
"type"
:
"object"
,
"properties"
:
{
"platform_ID"
:
{
...
...
This diff is collapsed.
Click to expand it.
formats/planning_configuration.py
View file @
806f47dc
...
...
@@ -157,7 +157,7 @@ squad_metadata_schema = {
}
planning_configuration_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/
definition
s/Message"
}],
"allOf"
:
[{
"$ref"
:
"#/
components/schema
s/Message"
}],
"type"
:
"object"
,
"properties"
:
{
"planning_config_ID"
:
{
...
...
This diff is collapsed.
Click to expand it.
formats/platform_status.py
View file @
806f47dc
...
...
@@ -26,7 +26,7 @@ sensor_schema = {
}
platform_status_message_schema
=
{
"allOf"
:
[{
"$ref"
:
"#/
definition
s/Message"
}],
"allOf"
:
[{
"$ref"
:
"#/
components/schema
s/Message"
}],
"type"
:
"object"
,
"properties"
:
{
"platform_ID"
:
{
...
...
This diff is collapsed.
Click to expand it.
generate_swagger.py
View file @
806f47dc
...
...
@@ -7,14 +7,12 @@ from formats.acknowledgement import acknowledgement_schema
from
flasgger
import
Swagger
from
flask
import
Flask
# from openapi_schema_validator import validate
from
openapi_spec_validator
import
validate_spec_url
app
=
Flask
(
__name__
)
swagger_config
=
{
"headers"
:
[],
"openapi"
:
"3.
1
"
,
"openapi"
:
"3.
0.2
"
,
"swagger_ui"
:
True
,
"specs_route"
:
"/"
,
"info"
:
{
...
...
@@ -30,13 +28,15 @@ swagger_config = {
"model_filter"
:
lambda
tag
:
True
,
}
],
"definitions"
:
{
"Message"
:
message_wrapper_schema
,
"MissionPlan"
:
mission_plan_schema
,
"Observation"
:
observation_schema
,
"PlanningConfiguration"
:
planning_configuration_schema
,
"PlatformStatus"
:
platform_status_message_schema
,
"Acknowledgement"
:
acknowledgement_schema
,
"components"
:
{
"schemas"
:
{
"Message"
:
message_wrapper_schema
,
"MissionPlan"
:
mission_plan_schema
,
"Observation"
:
observation_schema
,
"PlanningConfiguration"
:
planning_configuration_schema
,
"PlatformStatus"
:
platform_status_message_schema
,
"Acknowledgement"
:
acknowledgement_schema
,
}
},
"paths"
:
{
"/all_messages"
:
{
...
...
@@ -49,14 +49,26 @@ swagger_config = {
"application/json"
:
{
"schema"
:
{
"oneOf"
:
[
{
"$ref"
:
"#/definitions/Acknowledgement"
},
{
"$ref"
:
"#/definitions/PlatformStatus"
},
{
"$ref"
:
"#/definitions/MissionPlan"
},
{
"$ref"
:
"#/definitions/Observation"
},
{
"$ref"
:
"#/definitions/PlanningConfiguration"
"$ref"
:
"#/components/schemas/"
+
"Acknowledgement"
},
{
"$ref"
:
"#/components/schemas/"
+
"MissionPlan"
},
{
"$ref"
:
"#/components/schemas/"
+
"Observation"
},
{
"$ref"
:
"#/components/schemas/"
+
"PlanningConfiguration"
},
{
"$ref"
:
"#/components/schemas/"
+
"PlatformStatus"
},
{
"$ref"
:
"#/definitions/PlatformStatus"
},
],
"discriminator"
:
{
"propertyName"
:
"message_type"
,
...
...
@@ -92,7 +104,7 @@ for item in message_types:
"schema"
:
{
"allOf"
:
[
{
"$ref"
:
"#/
definition
s/"
+
item
,
"$ref"
:
"#/
components/schema
s/"
+
item
,
},
],
"discriminator"
:
{
...
...
@@ -108,23 +120,14 @@ for item in message_types:
swag
=
Swagger
(
app
,
config
=
swagger_config
,
merge
=
True
)
# validate({"acknowledged_message_ID": "string-type-id", "status": "c2_received"}, acknowledgement_schema)
# app.add_url_rule(
# '/coordinates',
# view_func=Coordinates.as_view('coordinates'),
# methods=['GET']
# )
from
openapi_spec_validator
import
validate_spec
,
openapi_v3_spec_validator
if
__name__
==
"__main__"
:
app
.
run
(
debug
=
True
)
# print(validate_spec_url("http://127.0.0.1:5000/swagger.json"))
# If no exception is raised by validate_spec(), the spec is valid.
#
#
If no exception is raised by validate_spec(), the spec is valid.
# validate_spec(swagger_config)
# print("000 Schema validation passed")
# errors_iterator = openapi_v3_spec_validator.iter_errors(swagger_config)
# print(errors_iterator)
\ No newline at end of file
# print(errors_iterator)
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment