[WIP] Attempts to enforce schema in dkist client response#557
Draft
Cadair wants to merge 1 commit intoDKISTDC:mainfrom
Draft
[WIP] Attempts to enforce schema in dkist client response#557Cadair wants to merge 1 commit intoDKISTDC:mainfrom
Cadair wants to merge 1 commit intoDKISTDC:mainfrom
Conversation
There was a problem hiding this comment.
Pull Request Overview
This pull request introduces a new module for parsing the OpenAPI specification of the dataset search API and enforcing type hints based on JSON schema definitions. Key changes include:
- Adding a new utility function (get_spec) to load the OpenAPI spec.
- Implementing a JsonSchemaTypeConverter class with methods to resolve JSON schema types into Python type hints.
- Providing a helper function (search_results_type_hints) to extract type hints for search result schemas.
Comments suppressed due to low confidence (1)
dkist/utils/openapi.py:36
- [nitpick] The error message 'No way friend' is informal and may lack clarity. Consider using a more descriptive and professional message to indicate that schema types starting with '_' are unsupported.
raise AttributeError("No way friend")
SolarDrew
approved these changes
Apr 24, 2025
Contributor
SolarDrew
left a comment
There was a problem hiding this comment.
To the extent that I understand anything that's going on here, LGTM 👍
| def get_type_handler(self, schema_type: str) -> Callable: | ||
| """Get a handler from this schema draft version.""" | ||
| if schema_type.startswith("_"): | ||
| raise AttributeError("No way friend") |
Contributor
There was a problem hiding this comment.
A more descriptive error message would probably be useful here.
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.