Closed jdkandersson closed 3 years ago
Create a cache. It takes a path to a specification file and exposes the following functions:
schemas_valid
: returns True
if the file has not changed since the last time validation was runschemas_are_valid
: Updates the cache to indicate the current version of the file is validCreate a file with the following name: __open_alchemy_<schemas filename where . is replaced with _>_cache__
The content of the file is:
{
"hash": "<sha256 hash of the file contents>",
"data": {
"schemas": {
"valid": true/false
}
}
}
schemas_valid
False
.False
.False
.hash
key, if it does not exist, return False
.False
.data.schemas.valid
key, if it does not exist, return False
.data.schemas.valid
is True
return True
, otherwise return False
.schemas_are_valid
hash
key in the dictionary to be the calculated value.data
key. If it does not exist or is not a dictionary, make it an empty dictionary.schemas
key under data
in the dictionary. If it does not exist or is not a dictionary, set it to be an empty dictionary.valid
key under data.schemas
and set it to True
.
As a user I want the startup to be faster after I have built a package so that my application is ready faster.
Every time OpenAlchemy starts up, the OpenAPI specification is validated against all rules. This is required if the OpenAPI specification can't be trusted. However, the validation is also run when the package is created during the build process. If a signature is included in the build the OpenAPI specification validation step can be skipped assuming the OpenAPI specification hasn't changed.
This can also be extended to be done if OpenAlchemy is run multiple times with the same spec by writing something to the file system.