-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ronald Krist
committed
Mar 9, 2023
1 parent
0cb826a
commit 8f56c25
Showing
12 changed files
with
78 additions
and
53 deletions.
There are no files selected for viewing
Empty file.
25 changes: 25 additions & 0 deletions
25
oarepo_model_builder_drafts/builders/parent_jsonschema_builder.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
from oarepo_model_builder.builders.json_base import JSONBaseBuilder | ||
from oarepo_model_builder.builders.jsonschema import JSONSchemaBuilder | ||
from oarepo_model_builder.stack import ModelBuilderStack | ||
|
||
|
||
class JSONSchemaDraftsParentBuilder(JSONSchemaBuilder): | ||
TYPE = "jsonschema_drafts_parent" | ||
output_file_type = "jsonschema" | ||
output_file_name = "drafts-parent-schema-file" | ||
parent_module_root_name = "jsonschemas" | ||
|
||
def begin(self, schema, settings): | ||
super().begin(schema, settings) | ||
target_json = { | ||
"$schema": "http://json-schema.org/draft-07/schema#", | ||
"$id": f"{schema.current_model.schema_server}{schema.current_model.drafts_parent_schema_name}", | ||
"type": "object", | ||
"properties": { | ||
"id": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
self.stack = ModelBuilderStack() | ||
self.stack.push(None, target_json) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 0 additions & 1 deletion
1
oarepo_model_builder_drafts/invenio/templates/invenio_drafts_record_extra_fields.py.jinja2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,17 @@ | ||
import copy | ||
from pathlib import Path | ||
from typing import Union | ||
|
||
from oarepo_model_builder.builder import ModelBuilder | ||
from oarepo_model_builder.conflict_resolvers import AutomaticResolver | ||
from oarepo_model_builder.entrypoints import create_builder_from_entrypoints | ||
from oarepo_model_builder.schema import ModelSchema | ||
from oarepo_model_builder.profiles import Profile | ||
|
||
from oarepo_model_builder.utils.hyphen_munch import HyphenMunch | ||
import munch | ||
|
||
|
||
class DraftsProfile(Profile): | ||
|
||
def build( | ||
self, | ||
model: ModelSchema, | ||
base_model: ModelSchema, | ||
output_directory: Union[str, Path], | ||
builder: ModelBuilder, | ||
): | ||
del model.current_model["known-classes"] | ||
model.schema.drafts = base_model.schema.model | ||
model.model_field = "drafts" | ||
builder.build(model, output_directory) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters