-
Notifications
You must be signed in to change notification settings - Fork 13
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
[GMS-1127] chore: Export api types from blockchain data package #971
Conversation
"apiPackage": "domain", | ||
"useSingleRequestParameter": true, | ||
"templateDir": "app/src/templates", | ||
"files": { |
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.
here is where the custom generators are allowed to be configured, we are doing this for mr only at the moment, hence the seperate config files
@@ -1,5 +1,16 @@ | |||
export * as imx from './imx'; | |||
export * as mr from './multi-rollup'; | |||
|
|||
export * as ActivitiesApi from './multi-rollup/domain/activities-api-types'; |
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 experimented with auto-generating a combined namespace for all these types, but it proved to be a hinderance later on when trying to re-export selected api types from the public blockchain data package. For now we are exporting all the api domains, and choosing to re-export only relevant ones from blockchain data (not passport or orders api)
7.0.1 |
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 required to upgrade the generator library version in order to resolve compile issues with the generated types. I went through the consuming packages of the generated clients internal package in the SDK and checked they all still compiled
@@ -0,0 +1,79 @@ | |||
{{#withSeparateModelsAndApi}} |
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.
These templates house additional generators that are run on top of existing generators. This api-types
one, of type 'API' (see config file above), generates a -type file per API.
1f74dc1
to
5cbc815
Compare
@@ -405,7 +406,9 @@ const endpointDomains = { | |||
}; | |||
|
|||
export default function Home() { | |||
const [response, setResponse] = useState(''); | |||
const [response, setResponse] = useState<ChainsApi.ListChainsResult | null>( |
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.
example usage
Summary
This PR adds custom generator templates to our internal openapi package for MR API, in order that API request and response types can be re-exported from our public blockchain data package.
The internal package exports types for every API, whilst the public blockchain data package exports types only for relevant API's (not Orders or Passport).
Read more about generator templates
See the sample app files for example usage.
Why the changes
Existing generators mix request/response types with other interfaces that we do not want to expose. Additional generators were required to be able to export only what we need.
Things worth calling out
Before submitting the PR, please consider the following:
feat:
,fix:
,chore:
,docs:
, orrefactor:
.