Skip to content

Commit

Permalink
schemas: allow extensions to be specified but None
Browse files Browse the repository at this point in the history
Editoast serialize *all* extensions, even when not present. The pydantic
validation should thus allow None

Signed-off-by: Younes Khoudli <younes.khoudli@epita.fr>
  • Loading branch information
Khoyo committed Dec 6, 2024
1 parent eec04ff commit 95d3c07
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 14 deletions.
55 changes: 44 additions & 11 deletions front/src/reducers/osrdconf/infra_schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,9 +187,12 @@
"BufferStopExtensions": {
"properties": {
"sncf": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/BufferStopSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -331,9 +334,12 @@
"DetectorExtensions": {
"properties": {
"sncf": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/DetectorSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -761,9 +767,12 @@
"NeutralSectionExtensions": {
"properties": {
"neutral_sncf": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/NeutralSectionNeutralSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -852,17 +861,23 @@
"OperationalPointExtensions": {
"properties": {
"identifier": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/OperationalPointIdentifierExtension"
},
{
"type": "null"
}
],
"default": null
},
"sncf": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/OperationalPointSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -927,9 +942,12 @@
"OperationalPointPartExtensions": {
"properties": {
"sncf": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/OperationalPointPartSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -1220,9 +1238,12 @@
"SignalExtensions": {
"properties": {
"sncf": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/SignalSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -1376,9 +1397,12 @@
"SpeedSectionExtensions": {
"properties": {
"psl_sncf": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/SpeedSectionPslSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -1474,9 +1498,12 @@
"SwitchExtensions": {
"properties": {
"sncf": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/SwitchSncfExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down Expand Up @@ -1662,17 +1689,23 @@
"TrackSectionExtensions": {
"properties": {
"sncf": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/TrackSectionSncfExtension"
},
{
"type": "null"
}
],
"default": null
},
"source": {
"allOf": [
"anyOf": [
{
"$ref": "#/$defs/TrackSectionSourceExtension"
},
{
"type": "null"
}
],
"default": null
Expand Down
2 changes: 1 addition & 1 deletion python/osrd_schemas/osrd_schemas/infra.py
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@ def register_extension(extension):
raise RuntimeError(f"Extension '{name}' already registered for {object.__name__}")

extensions_field.annotation.model_fields[name] = FieldInfo(
annotation=extension,
annotation=Optional[extension],
default=None,
)
return extension
Expand Down
4 changes: 2 additions & 2 deletions python/osrd_schemas/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
[project]
name = "osrd_schemas"
version = "0.8.13"
version = "0.8.14"

[tool.poetry]
name = "osrd_schemas"
version = "0.8.13"
version = "0.8.14"
description = ""
authors = ["OSRD <contact@osrd.fr>"]

Expand Down

0 comments on commit 95d3c07

Please sign in to comment.