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

[0.10] Support Smithy IDL Serialization #284

Merged
merged 16 commits into from
Feb 27, 2020
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Clarify documentation on IDL serializer outputs
  • Loading branch information
JordonPhillips committed Feb 24, 2020
commit 6fca073114eb353a7a859cc3b960bd40e3e634ce
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,15 @@ private SmithyIdlModelSerializer(Builder builder) {
/**
* Serializes a {@link Model} into a set of Smithy IDL files.
JordonPhillips marked this conversation as resolved.
Show resolved Hide resolved
*
* <p>This does not write the models to disk.
* <p>The output is a mapping
*
* <p>By default the paths are relative paths where each namespace is given its own file in the form
* "namespace.smithy". This is configurable via the shape placer, which can place shapes into absolute
* paths.
*
* <p>If the model contains no shapes, or all shapes are filtered out, then a single path "metadata.smithy"
* will be present. This will contain only any defined metadata.
*
* @param model The model to serialize.
* @return A map of (possibly relative) file paths to Smithy IDL strings.
*/
Expand Down Expand Up @@ -147,6 +155,9 @@ public static Builder builder() {
return new Builder();
}

/**
* Sorts shapes into files based on their namespace, where each file is named {namespace}.smithy.
*/
public static Path placeShapesByNamespace(Shape shape) {
JordonPhillips marked this conversation as resolved.
Show resolved Hide resolved
return Paths.get(shape.getId().getNamespace() + ".smithy");
}
Expand Down Expand Up @@ -254,6 +265,8 @@ public Builder traitFilter(Predicate<Trait> traitFilter) {
/**
* Function that determines what output file a shape should go in.
*
* <p>The returned paths may be absolute or relative.
*
* <p>NOTE: the Smithy IDL only supports one namespace per file.
JordonPhillips marked this conversation as resolved.
Show resolved Hide resolved
* @param shapePlacer Function that accepts a shape and returns file path.
* @return Returns the builder.
Expand Down