Skip to content

Commit 7a25aa1

Browse files
committed
fix!: use arrays for collections instead of sets
Because we have `uniqueItems: true` in our service definition yaml, fields with `type: array` are generated as `Set`s by the typescript generator. Serialization/deserialization of these types is [broken](OpenAPITools/openapi-generator#11746) so where we use these APIs [we pass arrays with `@ts-expect-error` anyway](https://github.com/ipfs/helia-remote-pinning/blob/main/src/heliaRemotePinner.ts#L155). It doesn't look possible to override the use of Set by the generator in a way that works (`type-mappings=set=array` produces uncompilable code) so manually change the generated code. Also adds a note to the readme reminding people to do it. BREAKING CHANGE: fields that were Sets such as `PinResults.results` and `PinsGetRequest.cid` are now Arrays
1 parent 152c535 commit 7a25aa1

File tree

5 files changed

+16
-14
lines changed

5 files changed

+16
-14
lines changed

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ npm run build
5353

5454
To update the client, you need to `npm run gen` npm script. This will fetch the latest version of the OpenAPI spec and generate the client. However, openapi-generator-cli does not currently generate the client code with proper import syntax. So you must modify the imports in `generated/fetch/**` directly, or just `git checkout -p` to remove the invalid import path changes.
5555

56+
It also uses `Set`s for all collection types though it cannot serialize or deserialize these types to/from JSON. They must be manually changed to be `Array`s.
57+
5658
If you need to modify the generated code's import paths, you will have to run `npm run postgen` manually.
5759

5860
### Contributing

generated/fetch/src/apis/PinsApi.ts

+6-6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/fetch/src/models/Pin.ts

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/fetch/src/models/PinResults.ts

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

generated/fetch/src/models/PinStatus.ts

+2-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)