-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a JsonSchemaMapperV2 interface rather than breaking original.
- Loading branch information
Showing
10 changed files
with
113 additions
and
32 deletions.
There are no files selected for viewing
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
58 changes: 58 additions & 0 deletions
58
...y-jsonschema/src/main/java/software/amazon/smithy/jsonschema/JsonSchemaMapperContext.java
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,58 @@ | ||
/* | ||
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
|
||
package software.amazon.smithy.jsonschema; | ||
|
||
import software.amazon.smithy.model.Model; | ||
import software.amazon.smithy.model.shapes.Shape; | ||
|
||
/** | ||
* Context for a JSON schema mapping. | ||
* | ||
* @param <T> Type of Smithy {@link Shape} being mapped. | ||
*/ | ||
public class JsonSchemaMapperContext<T extends Shape> { | ||
private final Model model; | ||
private final T shape; | ||
private final JsonSchemaConfig config; | ||
|
||
JsonSchemaMapperContext( | ||
Model model, | ||
T shape, | ||
JsonSchemaConfig config | ||
) { | ||
this.model = model; | ||
this.shape = shape; | ||
this.config = config; | ||
} | ||
|
||
/** | ||
* Gets the Smithy model being converted. | ||
* | ||
* @return Returns the Smithy model. | ||
*/ | ||
public Model getModel() { | ||
return model; | ||
} | ||
|
||
/** | ||
* Gets the Smithy shape being mapped. | ||
* | ||
* @return Returns the Smithy shape. | ||
*/ | ||
public T getShape() { | ||
return shape; | ||
} | ||
|
||
/** | ||
* Gets the JSON schema configuration object. | ||
* | ||
* @return Returns the JSON schema config object. | ||
*/ | ||
public JsonSchemaConfig getConfig() { | ||
return config; | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
smithy-jsonschema/src/main/java/software/amazon/smithy/jsonschema/JsonSchemaMapperV2.java
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,23 @@ | ||
/* | ||
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package software.amazon.smithy.jsonschema; | ||
|
||
import software.amazon.smithy.model.shapes.Shape; | ||
|
||
public interface JsonSchemaMapperV2 extends JsonSchemaMapper { | ||
default Schema.Builder updateSchema(Shape shape, Schema.Builder schemaBuilder, JsonSchemaConfig config) { | ||
return schemaBuilder; | ||
} | ||
|
||
/** | ||
* Updates a schema builder. | ||
* | ||
* @param context Context of this schema mapping. | ||
* @param schemaBuilder Schema builder to update. | ||
* @return Returns an updated schema builder. | ||
*/ | ||
Schema.Builder updateSchema(JsonSchemaMapperContext<? extends Shape> context, Schema.Builder schemaBuilder); | ||
} |
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
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