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

Paginated trait vs specification #1513

Closed
kubukoz opened this issue Nov 25, 2022 · 2 comments · Fixed by #1514
Closed

Paginated trait vs specification #1513

kubukoz opened this issue Nov 25, 2022 · 2 comments · Fixed by #1514

Comments

@kubukoz
Copy link
Contributor

kubukoz commented Nov 25, 2022

Hi! My understanding is that, if a service has the @paginated trait and none of its operations do, it's as if all the operations got the same @paginated trait:

Attaching the paginated trait to a service provides default pagination configuration settings to all operations bound within the closure of the service.

However, the PaginatedTraitValidator class doesn't seem to look at services at all, unless the operation is already annotated with @paginated.

Is there some transformation I'm missing (which would copy the trait to all of the service's operations)? Am I misunderstanding the spec? Or is the implementation incorrect?

Example (using scala-cli):

//> using lib "software.amazon.smithy:smithy-model:1.26.4"
import software.amazon.smithy.model.Model
import software.amazon.smithy.model.shapes.ShapeId

object a extends App {

  val s =
    """$version: "2"
      |namespace mytest
      |
      |@paginated(inputToken: "test", outputToken: "test")
      |service MyService {
      |  operations: [MyOperation]
      |}
      |
      |operation MyOperation {}""".stripMargin

  println {
    Model
      .assembler()
      .addUnparsedModel("test.smithy", s)
      .assemble()
      .unwrap()
      .expectShape(ShapeId.from("mytest#MyOperation"))
  }
}

I thought it would fail because of the missing test members in the operation's input and output, but it doesn't. It does break if you move the trait to the operation though.

@kstich
Copy link
Contributor

kstich commented Nov 25, 2022

Default pagination configuration from a service is only passed down to operations that are also marked with the @paginated trait. If the behavior applied without the operation-level trait, it would be impossible to have default pagination configuration on a service and bind non-paginated operations to it.

We should probably update that line of text to include that the operation must be @paginated as well for configuration to apply.

@kubukoz
Copy link
Contributor Author

kubukoz commented Nov 25, 2022

thanks, I appreciate the clarification!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants