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

Add Smithy API Specification and conversion to OpenAPI #87

Merged
merged 3 commits into from
Apr 30, 2024

Conversation

AshtonStephens
Copy link
Collaborator

Summary - Add Smithy API Specification

Resolves: #69

This PR creates a smithy API definition and a build script to turn it into an OpenAPI template. This follows the structure proposed in #80. It uses smithy to specify the API.

To turn the API into an OpenAPI spec at project root run smithy build and autogenerated sources will appear in sbtc-v1/.generated-sources/.

> cd APINAME
> smithy build

And then the autogenerated sources:

.generated-sources
├── classpath.json
├── openapi
│   ├── build-info
│   ├── model
│   ├── openapi
│   └── sources
└── source
    ├── build-info
    ├── model
    └── sources

Using Smithy

I chose smithy because making the OpenAPI template by hand proved too difficult and the autogenerated sources here make it a lot easier to change and understand the API. I was going to put in a segment a the Smithy specificiation versus the OpenAPI specification that it generates, but the OpenAPI specification that is autogenerated (and is actually smaller than I could have made by hand), is way too large to post here for a demo.

@AshtonStephens AshtonStephens self-assigned this Apr 30, 2024
@AshtonStephens AshtonStephens linked an issue Apr 30, 2024 that may be closed by this pull request
Copy link
Contributor

@djordon djordon left a comment

Choose a reason for hiding this comment

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

As far as I can tell, the definitions match up to what is in the LLD. Also the build instructions work as advertised. I ran smithy build in the api-definitions directory and the desired output magically appeared.

Left a small nit about ending in newlines and had a suggestion for the base64 regex.

structure UpdateChainstateInput {
@required blockHeight: Integer
@required blockHash: Base64EncodedBinary
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Style nit: I have a preference on ending files on a new line.

string BitcoinBlockHash
integer Satoshis

@pattern("^(?:[A-Za-z0-9+\/]{4})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=|[A-Za-z0-9+\/]{4})$")
Copy link
Contributor

Choose a reason for hiding this comment

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

I was able to find the pattern for base64 encoded data in this stackoverflow answer. Is there a better link for why this is correct? And is it worth adding a comment for it? I'm okay with the answer being "no".

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes I 1000% took that from that stack overflow answer. I'll add a comment citation.

@AshtonStephens AshtonStephens added the emily API that communicates with Signers to trigger sBTC operations. label Apr 30, 2024
@AshtonStephens AshtonStephens merged commit f509544 into main Apr 30, 2024
2 checks passed
@AshtonStephens AshtonStephens deleted the 69-deposit-api-openapi-template branch April 30, 2024 23:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
emily API that communicates with Signers to trigger sBTC operations.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Emily API Specification
2 participants