Skip to content
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

Support response types #33

Closed
LucaDe opened this issue Aug 28, 2019 · 13 comments · Fixed by #34
Closed

Support response types #33

LucaDe opened this issue Aug 28, 2019 · 13 comments · Fixed by #34

Comments

@LucaDe
Copy link
Contributor

LucaDe commented Aug 28, 2019

Currently response types are not typed (e.g. return type is always Promise< any >). It would be great to have these typed as well :)

I might look into this myself, when I find time!

@Manweill
Copy link
Owner

@LucaDe
Similar to #26. upgrade swagger-axios-codegen@latest

@LucaDe
Copy link
Contributor Author

LucaDe commented Aug 28, 2019

@Manweill
It's not working on v.0.7.0.
Sample:


const { codegen } = require('swagger-axios-codegen')

codegen({
  methodNameMode: 'operationId',
  remoteUrl:'https://webhook.apaleo.com/swagger/notification-v1/swagger.json',
  include: [
    'Subscriptions'
  ],
});

@Manweill
Copy link
Owner

I think i see what happen with it.
I rebuild and publish, fix in v0.7.1.

@LucaDe
Copy link
Contributor Author

LucaDe commented Aug 28, 2019

@Manweill
Thanks for rebuilding and publishing. Still same behaviour, response type is generated and added to GET requests, but not to POST/DELETE etc.

@Manweill
Copy link
Owner

@LucaDe
It has.

static createOrUpdateEquipment(
    params: {
      /**  */
      input?: CreateOrUpdateEquipmentInput;
    } = {} as any,
    options: IRequestOptions = {}
  ): Promise<number> {
    return new Promise((resolve, reject) => {
      let url = '/api/services/app/Equipment/CreateOrUpdateEquipment';

      const configs: IRequestConfig = getConfigs('post', 'application/json', url, options);

      let data = { ...params['input'] };

      configs.data = data;
      axios(configs, resolve, reject);
    });
  }

@LucaDe
Copy link
Contributor Author

LucaDe commented Aug 28, 2019

@Manweill
Could you check with my provided sample above? It should generate the SubscriptionCreatedResponseModel and add it to subscriptionsPost(..): Promise

@LucaDe
Copy link
Contributor Author

LucaDe commented Aug 28, 2019

@Manweill I just flew over the code for response type generation. It seems that you're only providing response types for a status code of 200. In my case the API returns a 201 as Statuscode, when a new Entity is created.

@Manweill
Copy link
Owner

I think it may be because I only deal with HttpCode 200.
I check with your swagger JSON. The Post method success HttpCode is 201.
I think it can add HttpCode is 20X response type.
But, How to deal with Delete method

@Manweill
Copy link
Owner

@LucaDe
Yeah, because my company's success code is only 200

@LucaDe
Copy link
Contributor Author

LucaDe commented Aug 28, 2019

I don't see why there should be a problem with DELETE methods. I will open a PR to accept 2XX status codes

@Manweill
Copy link
Owner

OK, Welcome PR~

@Manweill
Copy link
Owner

@LucaDe
Use yarn link with develop

@Manweill
Copy link
Owner

@LucaDe
Published.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants