-
Notifications
You must be signed in to change notification settings - Fork 16
Support http refs in Json Schema #273
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
Merged
Merged
Changes from 38 commits
Commits
Show all changes
40 commits
Select commit
Hold shift + click to select a range
a5faf62
Add support for http refs, and test it
Jacoby6000 c4f660a
Add more tests
Jacoby6000 305844c
Add test referencing model not included in the sources
Jacoby6000 a3aa87c
Setup a pre-compilation resolver step that pulls in remote refs
Jacoby6000 09a1020
Fix defSchema extraction
Jacoby6000 11fd13a
Minor cleanup
Jacoby6000 480e5a3
Cleanup, remote duplicate processing
Jacoby6000 cd9c212
Test duplicate remote/local definitions
Jacoby6000 b21c64b
Add and test remote ref allowlist
Jacoby6000 dfd38b9
Make http fileserver pick its own port to avoid port conflicts
Jacoby6000 896d1f8
Add CLI support for allowed refs
Jacoby6000 3424263
Make help string a little more clear
Jacoby6000 603d0be
Do less unneccessary work in unfoldPar
Jacoby6000 1d0c558
Delete empty added file
Jacoby6000 39e05fa
Reformat
Jacoby6000 ecd93c3
Support namespace remapping before/during JsonSchema IModel refold
Jacoby6000 a1f2f76
Add NamespaceMapping CLI Arg parsing test
Jacoby6000 e7e69a3
Add copyright headers
Jacoby6000 5114a97
Reformat
Jacoby6000 3fabcc1
Remove ref parser duplication
Jacoby6000 df97016
Move namespace remapping out of refparser
Jacoby6000 561bc3a
Remove empty namespaces from remapping
Jacoby6000 7d7699d
Improve error handling
Jacoby6000 900e6d5
reformat
Jacoby6000 7aec9b3
Better cli arg name for namespace remapping
Jacoby6000 6d287fb
Update modules/cli/src/opts/OpenAPIJsonSchemaOpts.scala
Jacoby6000 b443474
Merge upstream
Jacoby6000 797f102
Remove default args, add overloads to maintain source compat
Jacoby6000 523ec0f
Update help text
Jacoby6000 5c386d1
Add test suite for the NamespaceRemapper
Jacoby6000 c5986bf
Update builds to explicitly output java 11 bytecode
Jacoby6000 3eac131
Update CI to use newer java
Jacoby6000 03f6763
reformat
Jacoby6000 b8db5e5
Allow all tests to use newer jdk apis
Jacoby6000 524d922
Create headers
Jacoby6000 9cb920c
Reformat
Jacoby6000 d3400e0
Unmangle code broken by Create headers
Jacoby6000 128ad36
Add documentation for new cli args
Jacoby6000 b0b51c3
Remove comment about Java 18 in test
Jacoby6000 79404a0
Add comment about untracked IO
Jacoby6000 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,61 @@ | ||
| /* Copyright 2022 Disney Streaming | ||
| * | ||
| * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://disneystreaming.github.io/TOST-1.0.txt | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package smithytranslate.cli.opts | ||
|
|
||
| import com.monovore.decline._ | ||
| import cats.data.NonEmptyList | ||
| import cats.data.ValidatedNel | ||
| import cats.data.Validated | ||
| import cats.implicits._ | ||
| import cats.data.Chain | ||
| import cats.data.NonEmptyChain | ||
|
|
||
| object CommonArguments { | ||
| case class NamespaceMapping( | ||
| original: NonEmptyChain[String], | ||
| remapped: Chain[String] | ||
| ) | ||
| implicit val namespaceMappingArgument: Argument[NamespaceMapping] = | ||
| new Argument[NamespaceMapping] { | ||
| val defaultMetavar: String = "source.name.space:target.name.space" | ||
| def read(string: String): ValidatedNel[String, NamespaceMapping] = { | ||
| val result: Either[String, NamespaceMapping] = | ||
| string.split(':') match { | ||
| case Array(from, to) => | ||
| val sourceNs = | ||
| NonEmptyChain.fromSeq(from.split('.').toList.filter(_.nonEmpty)) | ||
| val targetNs = | ||
| Chain.fromSeq(to.split('.').toList.filter(_.nonEmpty)) | ||
|
|
||
| (sourceNs, targetNs) match { | ||
| case (None, _) => | ||
| Left("Source namespace must not be empty.") | ||
|
|
||
| case (Some(f), t) => | ||
| Right(NamespaceMapping(f, t)) | ||
| } | ||
| case _ => | ||
| Left( | ||
| s"""Invalid namespace remapping. | ||
| |Expected input to be formatted as 'my.source.namespace:my.target.namespace' | ||
| |got: '$string'""".stripMargin | ||
| ) | ||
| } | ||
|
|
||
| result.toValidatedNel | ||
| } | ||
| } | ||
| } | ||
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* Copyright 2022 Disney Streaming | ||
| * | ||
| * Licensed under the Tomorrow Open Source Technology License, Version 1.0 (the "License"); | ||
| * you may not use this file except in compliance with the License. | ||
| * You may obtain a copy of the License at | ||
| * | ||
| * https://disneystreaming.github.io/TOST-1.0.txt | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package smithytranslate.cli | ||
|
|
||
| import smithytranslate.cli.opts.CommonArguments | ||
| import cats.data.Validated | ||
| import cats.data.Chain | ||
| import cats.data.NonEmptyChain | ||
|
|
||
| class NamespaceMappingArgumentSpec extends munit.FunSuite { | ||
| test("NamespaceMapping Argument should - Parse a valid source:target") { | ||
| CommonArguments.namespaceMappingArgument.read("a.b.c:d.e.f") match { | ||
| case Validated.Valid(mapping) => | ||
| assertEquals( | ||
| mapping, | ||
| CommonArguments.NamespaceMapping( | ||
| original = NonEmptyChain("a", "b", "c"), | ||
| remapped = Chain("d", "e", "f") | ||
| ) | ||
| ) | ||
| case Validated.Invalid(errors) => | ||
| fail(s"Failed to parse valid input: ${errors.toList.mkString(", ")}") | ||
| } | ||
| } | ||
|
|
||
| test("NamespaceMapping Argument should - Parse a valid source:target with single part namespaces") { | ||
| CommonArguments.namespaceMappingArgument.read("a:b") match { | ||
| case Validated.Valid(mapping) => | ||
| assertEquals( | ||
| mapping, | ||
| CommonArguments.NamespaceMapping( | ||
| original = NonEmptyChain("a"), | ||
| remapped = Chain("b") | ||
| ) | ||
| ) | ||
| case Validated.Invalid(errors) => | ||
| fail(s"Failed to parse valid input: ${errors.toList.mkString(", ")}") | ||
| } | ||
| } | ||
|
|
||
| test("NamespaceMapping Argument should - successfully parse with an empty target") { | ||
lewisjkl marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| CommonArguments.namespaceMappingArgument.read("a.b.c:") match { | ||
| case Validated.Valid(mapping) => | ||
| assertEquals( | ||
| mapping, | ||
| CommonArguments.NamespaceMapping( | ||
| original = NonEmptyChain("a", "b", "c"), | ||
| remapped = Chain() | ||
| ) | ||
| ) | ||
| case Validated.Invalid(_) => | ||
| } | ||
| } | ||
|
|
||
| test("NamespaceMapping Argument should - fail to parse an invalid input missing colon") { | ||
| CommonArguments.namespaceMappingArgument.read("a.b.c") match { | ||
| case Validated.Valid(mapping) => fail(s"Parsed invalid input successfully: $mapping") | ||
| case Validated.Invalid(_) => | ||
| } | ||
| } | ||
|
|
||
| test("NamespaceMapping Argument should - fail to parse an invalid input with empty source") { | ||
| CommonArguments.namespaceMappingArgument.read(":a.b.c") match { | ||
| case Validated.Valid(mapping) => fail(s"Parsed invalid input successfully: $mapping") | ||
| case Validated.Invalid(_) => | ||
| } | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.