Closed odscjames closed 2 years ago
You can do it with https://ocdsextensionregistry.readthedocs.io/en/latest/api/profile_builder.html
You'd just need to pass it the package's extensions
array.
As for the OCDS version, I'm not sure if you want the latest patch, etc. In any case, for most use cases, it doesn't make much sense to use 1.0.x, since 1.1.x is backwards-compatible and generally more correct. If you do need the 1.0.x version, then it's easy: there are no extensions in 1.0, and there will be no further versions in the 1.0.x series, so just use https://standard.open-contracting.org/schema/1__0__3/ if the package has no version
key.
OCDS Kit does something similar here:
1.0.3 adds a get_ocds_patch_tag function, to simplify the above a bit:
In your case it'd probably look like:
from ocdsextensionregistry import ProfileBuilder
from ocdskit.util import get_ocds_patch_tag
tag = get_ocds_patch_tag(package.get("version", "1.0"))
builder = ProfileBuilder(tag, package.get("extensions", [])))
schema = builder.patched_release_schema()
Thank you @jpmckinney
I have a piece of data - a release package.
I need the schema that that data follows (ie correct OCDS version and with extensions applied), both the package and the release bit.
Is there a function in OCDSKit, or elsewhere, that does this?
(I couldn't see it - sorry if missed! Also COVE will do this work, but I haven't yet looked to see if it's in a form I can easily dig out.)
Thanks,