@@ -78,6 +78,101 @@ Important versions listed below. Refer to the [Changelog](CHANGELOG.md) for a fu
7878- [ 0.10.1-beta] ( CHANGELOG.md#v0101-beta ) - ** Alpaca compatible** 07.2018
7979- [ 0.9.5] ( CHANGELOG.md#095-27-Jun-2018 ) - ** Alpaca compatible** 07.2018
8080
81+ ## Notes on generation of catapult-rest DTO and API client
82+
83+ Following command can be used to generate DTOs and Api clients for the [ nem2-sdk-typescript-javascript] ( https://github.com/nemtech/nem2-sdk-typescript-javascript ) :
84+
85+ 1 . Download latest NEM2 swagger definition
86+ ``` bash
87+ $ git clone git@github.com:nemtech/nem2-docs
88+ $ cd nem2-docs && mkdir sdks && cd sdks
89+ $ cp ../source/resources/collections/swagger.yaml .
90+ ```
91+ 2. Copy OpenAPI generator template
92+
93+ Copy the ` templates` folder from {nem2-sdk-typescript-javascript}/infrastructure/ into ` sdk` folder
94+
95+ 3. Download OpenAPI generator and generate codes
96+ ` ` ` bash
97+ $ brew install openapi-generator
98+ $ openapi-generator generate -i ./swagger2.yaml -g typescript-node -t templates/ -o ./nem2-ts-sdk/ && rm -R nem2-ts-sdk/test
99+ ` ` `
100+ ** Note openapi-generator is also available on docker. (` https://hub.docker.com/r/openapitools/openapi-generator` )
101+ 4. Fix enum type definitions
102+
103+ As the generator doesn' t recognize `enum` type alias, we need to manually move enum classes in to the `enumsMap` list.
104+ - Open generated file `./nem2-ts-sdk/model/models.ts` in editor
105+ - Search for line contains `let enumsMap: {[index: string]: any}`.
106+ - Move all `xxxTypeEnum` entries from below `typeMap` into `enumsMap`.
107+
108+ example below:
109+ ```js
110+ let enumsMap: {[index: string]: any} = {
111+ "AccountPropertyTypeEnum": AccountPropertyTypeEnum,
112+ "AliasTypeEnum": AliasTypeEnum,
113+ "ResolutionStatementDTO": ResolutionStatementDTO,
114+ "MosaicPropertyIdEnum": MosaicPropertyIdEnum,
115+ "MultisigModificationTypeEnum": MultisigModificationTypeEnum,
116+ "NamespaceTypeEnum": NamespaceTypeEnum,
117+ "ReceiptTypeEnum": ReceiptTypeEnum,
118+ "RolesTypeEnum": RolesTypeEnum,
119+ }
120+
121+ let typeMap: {[index: string]: any} = {
122+ "AccountDTO": AccountDTO,
123+ "AccountIds": AccountIds,
124+ "AccountInfoDTO": AccountInfoDTO,
125+ "AccountMetaDTO": AccountMetaDTO,
126+ "AccountNamesDTO": AccountNamesDTO,
127+ "AccountPropertiesDTO": AccountPropertiesDTO,
128+ "AccountPropertiesInfoDTO": AccountPropertiesInfoDTO,
129+ "AccountPropertyDTO": AccountPropertyDTO,
130+ "AliasDTO": AliasDTO,
131+ "AnnounceTransactionInfoDTO": AnnounceTransactionInfoDTO,
132+ "BlockDTO": BlockDTO,
133+ "BlockInfoDTO": BlockInfoDTO,
134+ "BlockMetaDTO": BlockMetaDTO,
135+ "BlockchainScoreDTO": BlockchainScoreDTO,
136+ "CommunicationTimestamps": CommunicationTimestamps,
137+ "Cosignature": Cosignature,
138+ "HeightInfoDTO": HeightInfoDTO,
139+ "MerklePathItem": MerklePathItem,
140+ "MerkleProofInfo": MerkleProofInfo,
141+ "MerkleProofInfoDTO": MerkleProofInfoDTO,
142+ "MosaicDTO": MosaicDTO,
143+ "MosaicDefinitionDTO": MosaicDefinitionDTO,
144+ "MosaicIds": MosaicIds,
145+ "MosaicInfoDTO": MosaicInfoDTO,
146+ "MosaicMetaDTO": MosaicMetaDTO,
147+ "MosaicNamesDTO": MosaicNamesDTO,
148+ "MosaicPropertyDTO": MosaicPropertyDTO,
149+ "MultisigAccountGraphInfoDTO": MultisigAccountGraphInfoDTO,
150+ "MultisigAccountInfoDTO": MultisigAccountInfoDTO,
151+ "MultisigDTO": MultisigDTO,
152+ "NamespaceDTO": NamespaceDTO,
153+ "NamespaceIds": NamespaceIds,
154+ "NamespaceInfoDTO": NamespaceInfoDTO,
155+ "NamespaceMetaDTO": NamespaceMetaDTO,
156+ "NamespaceNameDTO": NamespaceNameDTO,
157+ "NetworkTypeDTO": NetworkTypeDTO,
158+ "NodeInfoDTO": NodeInfoDTO,
159+ "NodeTimeDTO": NodeTimeDTO,
160+ "ResolutionEntryDTO": ResolutionEntryDTO,
161+ "ServerDTO": ServerDTO,
162+ "ServerInfoDTO": ServerInfoDTO,
163+ "SourceDTO": SourceDTO,
164+ "StatementsDTO": StatementsDTO,
165+ "StorageInfoDTO": StorageInfoDTO,
166+ "TransactionHashes": TransactionHashes,
167+ "TransactionIds": TransactionIds,
168+ "TransactionInfoDTO": TransactionInfoDTO,
169+ "TransactionMetaDTO": TransactionMetaDTO,
170+ "TransactionPayload": TransactionPayload,
171+ "TransactionStatementDTO": TransactionStatementDTO,
172+ "TransactionStatusDTO": TransactionStatusDTO,
173+ }
174+ ```
175+
81176## License
82177
83178Copyright (c) 2018-2019 NEM
0 commit comments