-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
There was a problem hiding this 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 | ||
} |
There was a problem hiding this comment.
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})$") |
There was a problem hiding this comment.
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".
There was a problem hiding this comment.
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.
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 insbtc-v1/.generated-sources/
.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.