Skip to content

Commit

Permalink
Merge pull request #258 from Liturgical-Calendar:refactor-events-path
Browse files Browse the repository at this point in the history
refactor events path
  • Loading branch information
JohnRDOrazio authored Nov 16, 2024
2 parents f0a38af + 38549fb commit 37640a3
Show file tree
Hide file tree
Showing 6 changed files with 344 additions and 93 deletions.
10 changes: 10 additions & 0 deletions schemas/CommonDef.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
"pattern": "^(?:[a-z_]+?_){0,1}[A-Z][a-zA-Z1-9]+[0-9]{0,2}(?:_vigil)?$",
"description": "corresponds to the `event_key` property of liturgical events in the output of the LitCal API and similar endpoints"
},
"EventKeyVigilMass": {
"type": "string",
"pattern": "^(?:[a-z_]+?_){0,1}[A-Z][a-zA-Z1-9]+[0-9]{0,2}_vigil$",
"description": "corresponds to the `event_key` property of Vigil Mass liturgical events in the output of the LitCal API and similar endpoints"
},
"EventKeyNonVigilMass": {
"type": "string",
"pattern": "^(?:[a-z_]+?_){0,1}[A-Z][a-zA-Z1-9]+[0-9]{0,2}$",
"description": "corresponds to the `event_key` property of Non-Vigil Mass liturgical events in the output of the LitCal API and similar endpoints"
},
"LitColor": {
"type": "array",
"uniqueItems": true,
Expand Down
27 changes: 17 additions & 10 deletions schemas/LitCal.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,17 +100,18 @@
]
},
"litcal": {
"type": "object",
"type": "array",
"description": "the liturgical events that make up the requested Liturgical Calendar for the given year",
"patternProperties": {
"^(?:[a-z_]+?_){0,1}[A-Z][a-zA-Z1-9]+[0-9]{0,2}_vigil$": {
"$ref": "#/definitions/FestivityVigil"
},
"^(?:[a-z_]+?_){0,1}[A-Z][a-zA-Z1-9]+[0-9]{0,2}$": {
"$ref": "#/definitions/Festivity"
}
},
"additionalProperties": false
"items": {
"anyOf": [
{
"$ref": "#/definitions/Festivity"
},
{
"$ref": "#/definitions/FestivityVigil"
}
]
}
},
"messages": {
"type": "array",
Expand Down Expand Up @@ -306,6 +307,9 @@
"minimum": 0,
"maximum": 2000
},
"event_key": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/EventKeyVigilMass"
},
"name": {
"type": "string"
},
Expand Down Expand Up @@ -428,6 +432,9 @@
"minimum": 0,
"maximum": 2000
},
"event_key": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/EventKeyNonVigilMass"
},
"name": {
"type": "string"
},
Expand Down
158 changes: 78 additions & 80 deletions schemas/LitCalEventsPath.json
Original file line number Diff line number Diff line change
Expand Up @@ -72,87 +72,85 @@
"additionalProperties": false,
"definitions": {
"LitCalEvents": {
"type": "object",
"patternProperties": {
"^[A-Z](?:[A-Z]+_)*[a-zA-Z1-9]+[0-9]{0,2}(?:_vigil)?$": {
"type": "object",
"properties": {
"month": {
"type": "integer",
"format": "int32",
"minimum": 1,
"maximum": 12
},
"day": {
"type": "integer",
"format": "int32",
"minimum": 1,
"maximum": 31
},
"event_key": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/EventKey"
},
"grade": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/LitGrade"
},
"grade_lcl": {
"type": "string"
},
"grade_display": {
"type": "string"
},
"common": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/LitCommon"
},
"common_lcl": {
"type": "string"
},
"calendar": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/Calendar"
},
"color": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/LitColor"
},
"readings": {
"anyOf": [
{
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/Readings"
},
{
"type": "object",
"properties": {
"vigil": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/Readings"
},
"day": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/Readings"
}
},
"additionalProperties": false
}
]
},
"name": {
"type": "string",
"description": "The actual name of the liturgical event as defined in the latest edition of the source Roman Missal indicated in the key `MISSAL` (i.e. if the Missal is the Latin edition of the Roman Missal, the name should be from the latest edition of the Latin Roman Missal)"
},
"type": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/LitFeastType"
},
"missal": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/MissalID"
},
"decree": {
"type": "string",
"description": "When a liturgical event is defined ex-novo by a decree of the Congregation of Divine Worship rather than by a Roman Missal, this property will be present with a reference to the decree"
},
"strtotime": {
"type": "string"
}
"type": "array",
"items": {
"type": "object",
"properties": {
"month": {
"type": "integer",
"format": "int32",
"minimum": 1,
"maximum": 12
},
"additionalProperties": false,
"required": [ "event_key", "grade", "common", "common_lcl", "color", "name", "grade_lcl" ]
}
"day": {
"type": "integer",
"format": "int32",
"minimum": 1,
"maximum": 31
},
"event_key": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/EventKey"
},
"grade": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/LitGrade"
},
"grade_lcl": {
"type": "string"
},
"grade_display": {
"type": "string"
},
"common": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/LitCommon"
},
"common_lcl": {
"type": "string"
},
"calendar": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/Calendar"
},
"color": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/LitColor"
},
"readings": {
"anyOf": [
{
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/Readings"
},
{
"type": "object",
"properties": {
"vigil": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/Readings"
},
"day": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/Readings"
}
},
"additionalProperties": false
}
]
},
"name": {
"type": "string",
"description": "The actual name of the liturgical event as defined in the latest edition of the source Roman Missal indicated in the key `MISSAL` (i.e. if the Missal is the Latin edition of the Roman Missal, the name should be from the latest edition of the Latin Roman Missal)"
},
"type": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/LitFeastType"
},
"missal": {
"$ref": "https://litcal.johnromanodorazio.com/api/dev/schemas/CommonDef.json#/definitions/MissalID"
},
"decree": {
"type": "string",
"description": "When a liturgical event is defined ex-novo by a decree of the Congregation of Divine Worship rather than by a Roman Missal, this property will be present with a reference to the decree"
},
"strtotime": {
"type": "string"
}
},
"additionalProperties": false,
"required": [ "event_key", "grade", "common", "common_lcl", "color", "name", "grade_lcl" ]
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Core.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class Core
private ?string $JsonEncodedRequestHeaders = null;
private ?string $RequestContentType = null;
private ?string $ResponseContentType = null;
private static array $onlyUsefulHeaders = [
private const ONLY_USEFUL_HEADERS = [
"Accept", "Accept-Language", "X-Requested-With", "Origin"
];

Expand All @@ -46,7 +46,7 @@ public function __construct()
$this->AllowedRequestContentTypes = RequestContentType::$values;

foreach (getallheaders() as $header => $value) {
if (in_array($header, self::$onlyUsefulHeaders)) {
if (in_array($header, self::ONLY_USEFUL_HEADERS)) {
$this->RequestHeaders[$header] = $value;
}
}
Expand Down
Loading

0 comments on commit 37640a3

Please sign in to comment.