InterNetX / domainrobot-api

Swagger documentation for different APIs powered by InterNetX GmbH.
MIT License
18 stars 9 forks source link

broken #8

Closed patrickhilker closed 3 years ago

patrickhilker commented 4 years ago

Hello,

apart from this giving me the following error ...

 SyntaxError: '=' expected. (1619:33)
};

> export type JsonResponseDataByte[] = {
                                  ^
    'stid' ? : string;
    'messages' ? : Array < Message >
    ;

... your swagger files seem to be completely broken. After generating a typescript client I got 690 type errors when compiling. Most of them look like this:

Type 'number' is not assignable to type 'string'.
headers["X-Domainrobot-Owner-Context"] = parameters["xDomainrobotOwnerContext"];

If this lib had types I would switch, but without types that would be a major downgrade.

Ephenodrom commented 4 years ago

Hello @patrickhilker ,

How do you generate the client ?

We have never tried to create a client out of this swagger file, we use it only for documntation and generating model files. For some languages like Php, Dart und JS, we had to change some code in the Swagger Codegen tool, to generate up to date model files that can be used within our SDKs.

Therefore, it could be possible that the swagger code gen tool is broken for javascript.

A corresponding colleague was informed about the open issue in the Javascript SDK regarding types.

patrickhilker commented 4 years ago

Hey @Ephenodrom,

I am using this package to generate the typed typescript client. This is done once using a yarn script.

[...]

const code = CodeGen.getTypescriptCode({
        className: "InternetXAPIClient",
        swagger,
    });

[...]

The resulting code is then saved to a file.

adelholtz commented 3 years ago

Hi,

i have looked into "Swagger to Typescript Codegen" package and tried it. I have also reviewed our swagger file, and while there are indeed some structural errors, these errors do not lead to the Type errors like this:

 headers['X-Domainrobot-Demo'] = parameters['xDomainrobotDemo'];  //Type 'number' is not assignable to type 'string'

The problem here ist that the package declares the header Paramaters as 'string' in a very general way which does not correspond to the definition in the swagger file.

export type RequestHeaders = {
    [header: string]: string;
}

I have tried to find out why the package does this but came to no conclusion. The defintion of the headers is correct as can be read in detail here: https://swagger.io/docs/specification/2-0/describing-parameters/#header-parameters

So for now i advise to not use the package or just use it for less complicated swagger files.

I will close this ticket for now since we have another discussion regarding type definitions going on here: https://github.com/InterNetX/js-domainrobot-sdk/issues/6 which should hopefully solve your issues.

If you have any more questions, feedback or anything else please do not hesitate to contact us.

Have a nice day!

InterNetX-DL commented 3 years ago

Closed at @adelholtz 's suggestion