johnstonskj / rust-atelier

Rust native core model for the AWS Smithy IDL
MIT License
76 stars 10 forks source link

[BUG] Model builder ignores operation output member, incorrectly stores input member in output member field #31

Closed stevelr closed 3 years ago

stevelr commented 3 years ago

Describe the bug When parsing a model, the operation builder sets both the input and output members to the input

To Reproduce save the following as /tmp/foo.smithy:

namespace org.example

operation Oops {
    input: String,
    output: Blob
}

run cargo-atelier convert -r smithy -w json -i /tmp/foo.smithy The output you get is:

{
  "shapes": {
    "org.example#Oops": {
      "input": {
        "target": "smithy.api#String"
      },
      "output": {
        "target": "smithy.api#String"
      },
      "type": "operation"
    }
  },
  "smithy": "1.0"
}%

As you can see, output:Blob is ignored. The input member is stored into both the input and output targets.

I tracked the bug to here: https://github.com/johnstonskj/rust-atelier/blob/698193625b090f8d3f1067ddffefaaa3219228cc/atelier-core/src/builder/mod.rs#L579

This line is probably a copy-paste error from seven lines above: https://github.com/johnstonskj/rust-atelier/blob/698193625b090f8d3f1067ddffefaaa3219228cc/atelier-core/src/builder/mod.rs#L572

The line 579 version should replace builder.input with builder.output

johnstonskj commented 3 years ago

Can you create a stand-alone PR for this issue please? Just the one commit, and I'll get it merged onto the new changes.