@angular/http is still used in interface. The interface codes cannot find required model types. The related classes cannot resolve interface files.
swagger-codegen-cli-2.4.0-20180222.131322-150.jar
modules/swagger-codegen/src/test/resources/2_0/petstore.yaml
java -jar swagger-codegen-cli-2.4.0-20180222.131322-150.jar generate -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l typescript-angular -c bin/typescript-petstore-npm.json -o samples/client/petstore/typescript-angular-v4.3/npm --additional-properties ngVersion=4.3 -D withInterfaces=true
add usehttpclient support in apiInterface.mustache
I am experiencing the same issue
I fix it for now issue7711. If this bug is approved, I will send a pull request.
@liuy97 the code change in https://github.com/liuy97/swagger-codegen/commit/22c1b1ea431df0db7c592ef5bc2c84ab958a515c#diff-0a6663407a0b68718b67567a38ca1b20R2 seems legitimate, so would you mind opening a PR to fix this?
For those who use withInterfaces, can you tell me your use cases for them? I'm still not sure why we have this feature and was considering suggesting it be deprecated.
Sorry, I'm unaware that "withInterfaces" will be deprecated. We use this feature in some projects, especially for mocking testing data.
@liuy97
I'm on the technical committee so I'm always considering features we should and shouldn't support. That's why I spoke of deprecation.
If you could, please explain more what you mean by mocking? I've never needed extra interfaces to mock the services generated by this project. Maybe it is just a difference of strategy?
In our testing cases, we have tens of services, and each component has a few injecting services. It will be difficult to spyon service methods and supply return values in each component unit testing. (Unit testing can be of course achieved without service interfaces.) We predefine mocking service providers of service interface instances in one place. It's convenient for us.
I do the same thing. The stubs that is used in unit tests implement the interface generated by swagger codegen. This way is is easy to make sure that the stub is in sync with the actual API service. It also speeds up making these stubs since the declaration of functions can be auto-generated by the IDE.
@liuy97 @jagrodal
I see your points, this seems to be a very helpful feature so I'll try to keep that in mind in the future.
Our perspectives were slightly different. I didn't rely on the library itself to generate them. My team created the mocks based off the models before these were here.
@liuy97 @jagrodal
I'll look into instead of just generating the interfaces, actually generating the spied classes based on the yaml. That way you never have to update the mocks at all.
@kenisteward did you manage to look into generating the spied classes?
Most helpful comment
I am experiencing the same issue