Skip to content

Move javadoc to StructureGenerator #546

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 1 commit into from
May 24, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -282,48 +282,13 @@ protected Void getDefault(Shape shape) {
return null;
}

/**
* Renders structures as interfaces.
*
* <p>A namespace is created with the same name as the structure to
* provide helper functionality for checking if a given value is
* known to be of the same type as the structure. This will be
* even more useful if/when inheritance is added to Smithy.
*
* <p>Note that the {@code required} trait on structures is used to
* determine whether or not a generated TypeScript interface uses
* required members. This is typically not recommended in other languages
* since it's documented as backward-compatible for a model to migrate a
* required property to optional. This becomes an issue when an older
* client consumes a service that has relaxed a member to become optional.
* In the case of sending data from the client to the server, the client
* likely either is still operating under the assumption that the property
* is required, or the client can set a property explicitly to
* {@code undefined} to fix any TypeScript compilation errors. In the
* case of deserializing a value from a service to the client, the
* deserializers will need to set previously required properties to
* undefined too.
*
* <p>The generator will explicitly state that a required property can
* be set to {@code undefined}. This makes it clear that undefined checks
* need to be made when using {@code --strictNullChecks}, but has no
* effect otherwise.
*
* @param shape Shape being generated.
*/
@Override
public Void structureShape(StructureShape shape) {
writers.useShapeWriter(shape, writer ->
new StructureGenerator(model, symbolProvider, writer, shape, settings.generateServerSdk()).run());
return null;
}

/**
* Renders a TypeScript union.
*
* @param shape Shape to render as a union.
* @see UnionGenerator
*/
@Override
public Void unionShape(UnionShape shape) {
writers.useShapeWriter(shape, writer ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,32 @@

/**
* Generates normal structures and error structures.
*
* Renders structures as interfaces.
*
* <p>A namespace is created with the same name as the structure to
* provide helper functionality for checking if a given value is
* known to be of the same type as the structure. This will be
* even more useful if/when inheritance is added to Smithy.
*
* <p>Note that the {@code required} trait on structures is used to
* determine whether or not a generated TypeScript interface uses
* required members. This is typically not recommended in other languages
* since it's documented as backward-compatible for a model to migrate a
* required property to optional. This becomes an issue when an older
* client consumes a service that has relaxed a member to become optional.
* In the case of sending data from the client to the server, the client
* likely either is still operating under the assumption that the property
* is required, or the client can set a property explicitly to
* {@code undefined} to fix any TypeScript compilation errors. In the
* case of deserializing a value from a service to the client, the
* deserializers will need to set previously required properties to
* undefined too.
*
* <p>The generator will explicitly state that a required property can
* be set to {@code undefined}. This makes it clear that undefined checks
* need to be made when using {@code --strictNullChecks}, but has no
* effect otherwise.
*/
@SmithyInternalApi
final class StructureGenerator implements Runnable {
Expand Down