Skip to content
Open
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 @@ -17,8 +17,6 @@

import software.amazon.smithy.codegen.core.CodegenException;
import software.amazon.smithy.codegen.core.Symbol;
import software.amazon.smithy.model.knowledge.HttpBinding.Location;
import software.amazon.smithy.model.knowledge.HttpBindingIndex;
import software.amazon.smithy.model.shapes.BigDecimalShape;
import software.amazon.smithy.model.shapes.BigIntegerShape;
import software.amazon.smithy.model.shapes.BlobShape;
Expand All @@ -43,6 +41,7 @@
import software.amazon.smithy.model.shapes.StructureShape;
import software.amazon.smithy.model.shapes.TimestampShape;
import software.amazon.smithy.model.shapes.UnionShape;
import software.amazon.smithy.model.traits.TimestampFormatTrait;
import software.amazon.smithy.model.traits.TimestampFormatTrait.Format;
import software.amazon.smithy.typescript.codegen.TypeScriptDependency;
import software.amazon.smithy.typescript.codegen.integration.ProtocolGenerator.GenerationContext;
Expand Down Expand Up @@ -234,8 +233,9 @@ public final String memberShape(MemberShape shape) {

@Override
public String timestampShape(TimestampShape shape) {
HttpBindingIndex httpIndex = HttpBindingIndex.of(context.getModel());
Format format = httpIndex.determineTimestampFormat(shape, Location.DOCUMENT, defaultTimestampFormat);
Format format = shape.getTrait(TimestampFormatTrait.class)
.map(trait -> Format.fromString(trait.getValue()))
.orElse(defaultTimestampFormat);
return HttpProtocolGeneratorUtils.getTimestampInputParam(context, dataSource, shape, format);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

I think it should be this:

no codegen diff in all aws sdks?

    @Override
    public String timestampShape(TimestampShape shape) {
        Format format = shape.getMemberTrait(context.getModel(), TimestampFormatTrait.class)
            .map(TimestampFormatTrait::getFormat)
            .orElse(defaultTimestampFormat);
        
        return HttpProtocolGeneratorUtils.getTimestampInputParam(context, dataSource, shape, format);
    }


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import software.amazon.smithy.model.traits.MediaTypeTrait;
import software.amazon.smithy.model.traits.SparseTrait;
import software.amazon.smithy.model.traits.StreamingTrait;
import software.amazon.smithy.model.traits.Trait;
import software.amazon.smithy.utils.MapUtils;

/**
Expand All @@ -28,7 +29,7 @@
*/
public class SerdeElisionIndex implements KnowledgeIndex {
private final Map<ShapeId, Boolean> elisionBinding = new HashMap<>();
private final Map<String, Class> mutatingTraits = MapUtils.of(
private final Map<String, Class<? extends Trait>> mutatingTraits = MapUtils.of(
"jsonName", JsonNameTrait.class,
"streaming", StreamingTrait.class,
"mediaType", MediaTypeTrait.class,
Expand Down Expand Up @@ -58,7 +59,7 @@ private boolean canBeElided(Shape shape, Model model) {
}

private boolean hasMutatingTraits(Shape shape, Model model) {
for (Map.Entry<String, Class> entry : mutatingTraits.entrySet()) {
for (Map.Entry<String, Class<? extends Trait>> entry : mutatingTraits.entrySet()) {
if (shape.hasTrait(entry.getValue())) {
return true;
}
Expand Down
Loading