ScaleLeap / selling-partner-api-sdk

A fully typed TypeScript and Node.js SDK library for Amazon Selling Partner API
https://npm.im/@scaleleap/selling-partner-api-sdk
MIT License
68 stars 28 forks source link

export all enums #60

Closed michael-land closed 3 years ago

michael-land commented 3 years ago

image

I think it would be nice to import types/enums from root

import { OrderOrderStatusEnum,  or whatever enums/types/interfaces } from '@scaleleap/selling-partner-api-sdk';

or maybe use string/number literal types instead of enums

moltar commented 3 years ago

@xiaoyu-tamu There's a problem because this is generated from models, and entities inside models have duplicate names. That's why it's not possible to export from root.

But if you have any technical proposals, we can certainly look into it.

michael-land commented 3 years ago

You're right.

I never used OpenAPI generator before, i'm not sure if this is possible.

map this

    /**
     * The current order status.
     * @type {string}
     * @memberof Order
     */
    OrderStatus: OrderOrderStatusEnum;

to

    /**
     * The current order status.
     * @type {string}
     * @memberof Order
     */
    OrderStatus: 'Pending' | 'Unshipped' | 'PartiallyShipped' | 'Shipped' | 'Canceled' | 'Unfulfillable' | 'InvoiceUnconfirmed' | 'PendingAvailability';

So, we can get typesafe without export duplicated enums

moltar commented 3 years ago

@nguyentoanit please investigate if this is possible

moltar commented 3 years ago

@xiaoyu-tamu the problem is really not with OpenAPI, but with the way SP API models are designed. It should have been just one model, and no dups, or even if they for some reason wanted to split it up into multiple models, they should have ensured there were not any duplication of names and just namespace all of the entities, but they didn't do that :/

I am in favor of getting rid of enums, as I also think it is annoying to use them.

Hopefully @nguyentoanit can figure out a solution.

github-actions[bot] commented 3 years ago

:tada: This issue has been resolved in version 2.0.0 :tada:

The release is available on:

Your semantic-release bot :package::rocket: