Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip unrecognized JSON files when loading models #1846

Merged
merged 1 commit into from
Jul 6, 2023

Conversation

mtdowling
Copy link
Member

Issue #, if available: #1841

Description of changes:

This commit updates the model loading process so that JSON files that are not objects or that don't contain a top-level "smithy" key are skipped. This can be useful when loading directories that contain Smithy models mixed with other JSON files. JAR files that contain Smithy models are not permitted to refer to unrecognized JSON files that lack a valid "smithy" version key/value pair.

This commit also only creates InputStreams for files that Smithy can actually load or attempt to load. Smithy would previously open an InputStream for all recursive files in a directory even if it was unable to load the file based on the filename. It now only creates an InputStream when the file has a .json, .smithy, or no file extension.

Closes #1841

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@mtdowling mtdowling requested a review from a team as a code owner July 5, 2023 21:50
@mtdowling mtdowling force-pushed the ignore-unrecognized-json-files branch from 794eb0a to c2113f1 Compare July 5, 2023 21:53
Copy link
Contributor

@kstich kstich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like issues with Windows CI, I had issues with Paths.get formatting Windows paths improperly because they needed to be URIs to encode correctly.

@mtdowling mtdowling force-pushed the ignore-unrecognized-json-files branch from c2113f1 to 61fcec8 Compare July 6, 2023 02:51
@mtdowling mtdowling force-pushed the ignore-unrecognized-json-files branch from 61fcec8 to 9937a40 Compare July 6, 2023 18:35
This commit updates the model loading process so that JSON files that
are not objects or that don't contain a top-level "smithy" key are
skipped. This can be useful when loading directories that contain
Smithy models mixed with other JSON files. JAR files that contain
Smithy models are not permitted to refer to unrecognized JSON files
that lack a valid "smithy" version key/value pair.

This commit also only creates InputStreams for files that Smithy can
actually load or attempt to load. Smithy would previously open an
InputStream for all recursive files in a directory even if it was
unable to load the file based on the filename. It now only creates an
InputStream when the file has a .json, .smithy, or no file extension.

Closes #1841
@mtdowling mtdowling force-pushed the ignore-unrecognized-json-files branch from 9937a40 to 328c955 Compare July 6, 2023 18:51
@mtdowling mtdowling requested a review from kstich July 6, 2023 19:04
@mtdowling mtdowling merged commit e6ee644 into main Jul 6, 2023
@kubukoz
Copy link
Contributor

kubukoz commented Jul 6, 2023

@mtdowling do you have a timeline for the next release? This and #1838 would be really nice to have for my team.

@mtdowling
Copy link
Member Author

We're planning for a Monday release

@kubukoz
Copy link
Contributor

kubukoz commented Jul 6, 2023

awesome, thanks!

@mtdowling mtdowling deleted the ignore-unrecognized-json-files branch September 11, 2023 18:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CLI: ignore non-Smithy-model JSON files?
3 participants