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

UrlForm decoding support #1113

Merged
merged 43 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
7ab3c8d
Update tests to cover decoding, fix various bugs uncovered by them
dhpiggott Jul 27, 2023
e20d0d3
Consolidate cursor behaviour within UrlFormCursor
dhpiggott Aug 2, 2023
5d0e251
Remove redundant FailedValue cursor type
dhpiggott Aug 2, 2023
7accb71
Use headOption, not head
dhpiggott Aug 2, 2023
c4d1ae6
Further cursor simplification
dhpiggott Aug 2, 2023
bc174d2
Handle renaming TODOs
dhpiggott Aug 2, 2023
a5fc091
Flatten UrlForm types by making encoder and decoder cursor work with …
dhpiggott Aug 2, 2023
5ceae82
Flatten UrlFormCursor
dhpiggott Aug 2, 2023
e2466f5
Handle TODO re. DRYing error messages
dhpiggott Aug 2, 2023
679c682
Remove TODO
dhpiggott Aug 2, 2023
c100080
Make spec test primitive decoding too
dhpiggott Aug 2, 2023
e99c5cb
Remove redundant UrlFormParserSpec
dhpiggott Aug 2, 2023
06cf841
Fix codecs
dhpiggott Aug 2, 2023
e1c8cd0
First pass of OAuthCodecs
dhpiggott Aug 2, 2023
149f826
First pass of sandbox clients and servers
dhpiggott Aug 3, 2023
b60496d
Fix copyright headers
dhpiggott Aug 8, 2023
83d6d3c
Apply suggestions from code review
dhpiggott Aug 8, 2023
a96480c
Scalafmt
dhpiggott Aug 8, 2023
2701b0f
Remove redundant dependency
dhpiggott Aug 8, 2023
5ac670f
Convert oauth-sandbox apps to Cats Effect
dhpiggott Aug 8, 2023
1f43fd4
Move OAuthCodecs to http4s module
dhpiggott Aug 8, 2023
ddb8f30
Remove redundant TODO
dhpiggott Aug 9, 2023
4ed323e
Remove TODO re. PayloadCodec
dhpiggott Aug 9, 2023
0e97a74
Remove redundant TODO and fix bug in Blob
dhpiggott Aug 9, 2023
9068eae
Revert previous bug fix, add test, verify it fails
dhpiggott Aug 9, 2023
4a42267
Reapply bug fix, verify new test passes
dhpiggott Aug 9, 2023
ecfbeee
Fold UrlFormParser into UrlForm, restrict internals visibility
dhpiggott Aug 9, 2023
7f9e8d0
Scalafmt
dhpiggott Aug 9, 2023
58d39eb
Update TODOs re. downstreaming
dhpiggott Aug 9, 2023
40b6754
Remove queryFlattened and queryName
dhpiggott Aug 10, 2023
ed9b4dc
Make URL form support work using urlFormFlattened and urlFormName
dhpiggott Aug 10, 2023
e4337de
Fix OAuthCodecs
dhpiggott Aug 10, 2023
841fa69
Merge branch 'series/0.18' into url-form-decoding-support
dhpiggott Aug 11, 2023
eccb3b7
Fix enum handling
dhpiggott Aug 11, 2023
824c479
Remove OAuthCodecs and oauth-sandbox
dhpiggott Aug 11, 2023
dfe3eb2
Fix aws-sandbox directory
dhpiggott Aug 11, 2023
ffba6d7
Merge branch 'series/0.18' into url-form-decoding-support
dhpiggott Aug 14, 2023
e8d0a89
Fix imports
dhpiggott Aug 14, 2023
8c081b6
Use locally for readability
dhpiggott Aug 14, 2023
e28d74d
Use groupMap
dhpiggott Aug 14, 2023
18a723d
s/list/vector/
dhpiggott Aug 14, 2023
b0ad4eb
Fix use of groupMap for Scala 2.12
dhpiggott Aug 14, 2023
033173c
Oops, too hasty with "dead" code removal
dhpiggott Aug 14, 2023
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
5 changes: 0 additions & 5 deletions modules/core/src-2.12/ScalaCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,4 @@ private[smithy4s] trait ScalaCompat {
private def opt[A](a: => A): Option[A] = try { Some(a) }
catch { case scala.util.control.NonFatal(_) => None }
}

private[smithy4s] implicit final class MapOps[K, V](val map: Map[K, V]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't see this being used anywhere.

def mapToValues[W](f: V => W): Map[K, W] = map.mapValues(f)
}

}
6 changes: 1 addition & 5 deletions modules/core/src-2.13/ScalaCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@

package smithy4s

private[smithy4s] trait ScalaCompat {
implicit final class MapOps[K, V](val map: Map[K, V]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't see this being used anywhere.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Should I merge the 2.13 and 3 ScalaCompat versions under src?

def mapToValues[W](f: V => W): Map[K, W] = map.view.mapValues(f).toMap
}
}
private[smithy4s] trait ScalaCompat {}
6 changes: 1 addition & 5 deletions modules/core/src-3/ScalaCompat.scala
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,4 @@

package smithy4s

private[smithy4s] trait ScalaCompat {
implicit final class MapOps[K, V](val map: Map[K, V]) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Couldn't see this being used anywhere.

def mapToValues[W](f: V => W): Map[K, W] = map.view.mapValues(f).toMap
}
}
private[smithy4s] trait ScalaCompat {}
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,7 @@ private[http] class UrlFormDataDecoderSchemaVisitor(
// https://smithy.io/2.0/aws/protocols/aws-ec2-query-protocol.html?highlight=ec2%20query%20protocol#query-key-resolution.
ignoreUrlFormFlattened: Boolean,
capitalizeStructAndUnionMemberNames: Boolean
) extends SchemaVisitor.Cached[UrlFormDataDecoder]
with smithy4s.ScalaCompat {
compile =>
) extends SchemaVisitor.Cached[UrlFormDataDecoder] { compile =>

override def primitive[P](
shapeId: ShapeId,
Expand All @@ -49,6 +47,7 @@ private[http] class UrlFormDataDecoderSchemaVisitor(
}
}

@annotation.nowarn("msg=Unused import")
override def collection[C[_], A](
shapeId: ShapeId,
hints: Hints,
Expand All @@ -74,6 +73,7 @@ private[http] class UrlFormDataDecoderSchemaVisitor(
//
// We can't assume they were encoded in order. That's why we have to
// then sort by index.
import scala.collection.compat._
val groupedAndSortedCursors = values
.collect {
case formData @ UrlForm.FormData(
Expand All @@ -88,11 +88,9 @@ private[http] class UrlFormDataDecoderSchemaVisitor(
index
}
.map { case (index, values) =>
UrlFormCursor(
history,
values
UrlFormCursor(history, values).down(
PayloadPath.Segment.Index(index)
)
.down(PayloadPath.Segment.Index(index))
}
groupedAndSortedCursors
.traverse[UrlFormDecodeError, A](memberDecoder.decode(_))
Copy link
Contributor

Choose a reason for hiding this comment

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

if the toVector is only there to satisfy the traverse, we can change/overload our traverse to accommodate the data structure and save an un-necessary .toVector call

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It is and it isn't. The result of groupBy (and groupMap) is a Map, but we have to sort things before producing a result so that we're not making assumptions about input order. Map isn't sortable. I did initially write toList and puzzle over the compile error, before changing it to toVector. So it's toVector rather than toList to satisfy the traverse, but not toVector rather nothing to satisfy the traverse.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ import cats.kernel.Monoid

private[smithy4s] class XmlEncoderSchemaVisitor(
val cache: CompilationCache[XmlEncoder]
) extends SchemaVisitor.Cached[XmlEncoder]
with smithy4s.ScalaCompat { compile =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unused.

) extends SchemaVisitor.Cached[XmlEncoder] { compile =>

def primitive[P](
shapeId: ShapeId,
Expand Down
Loading