[ts-angular]: add ts-ignore directives to avoid compilation errors#10713
[ts-angular]: add ts-ignore directives to avoid compilation errors#10713macjohnny merged 1 commit intoOpenAPITools:masterfrom verokarhu:add-ts-ignore-directive-to-ts-angular
Conversation
The unused imports don't pass stricter TS compiler settings.
|
@TiFu (2017/07) @taxpon (2017/07) @sebastianhaas (2017/07) @kenisteward (2017/07) @Vrolijkx (2017/09) @macjohnny (2018/01) @topce (2018/10) @akehir (2019/07) @petejohansonxo (2019/11) @amakhrov (2020/02) |
amakhrov
left a comment
There was a problem hiding this comment.
Looks good.
Interesting that you don't experience issues with models (which often produce unused imports for combined schemas like allOf)
|
|
||
| {{#imports}} | ||
| // @ts-ignore | ||
| import { {{ classname }} } from '{{ filename }}'; |
There was a problem hiding this comment.
could you add an example case where this imports an unused model? maybe it's something we should (and can) fix in the generator?
In my project all such cases are related to the shape of error responses (non-200 responses) - but also not of them, so there definitely is someting wweird around that.
Do you know of other cases?
There was a problem hiding this comment.
I think the root cause is that there is no support for multiple kinds of responses from the same endpoint. This is a distilled version of the schema that I'm using:
openapi: 3.0.0
info:
description: example
title: example
version: version1
paths:
/example:
get:
responses:
"200":
description: success
content:
"application/json":
schema:
$ref: "#/components/schemas/Success"
default:
description: problem
content:
"application/problem+json":
schema:
$ref: "#/components/schemas/Problem"
components:
schemas:
Success:
properties:
value:
type: string
Problem:
properties:
value:
type: string
There was a problem hiding this comment.
unpopular opinion: generated code should not be linted.
There was a problem hiding this comment.
Fully agree, but still there are many that want to lint it
* OpenAPITools-master: (457 commits) [java][jersey2] remove warning using JsonMapper.builder (OpenAPITools#10734) update scribejava to 8.x (OpenAPITools#10733) [powershell] add file upload support (OpenAPITools#10735) Add openapi-generator kotlin article (OpenAPITools#10731) [ts-angular]: add ts-ignore directives to avoid compilation errors (OpenAPITools#10713) rebalance circleci tests (OpenAPITools#10727) [java][okhttp-gson] update dependencies in pom.xml (OpenAPITools#10709) [java][jersey2] update plugins in pom.xml (OpenAPITools#10710) Fix library generation compatibility with Gradle 7.2 (OpenAPITools#10716) [kotlin-spring] change the suffix from ".kt" to "Controller.kt" when generating a controller class (OpenAPITools#10671) [cpprestsdk] CMake build system improvements (OpenAPITools#10660) adds get/setHasMultipleTypes to Java schema classes (OpenAPITools#10715) update microprofile to newer version (OpenAPITools#10714) Typescript saga immutablejs enhancements and small fixes (OpenAPITools#10444) add an option for configKey (OpenAPITools#10707) Allow specification of configkey for microprofile clients (OpenAPITools#10693) Update crystal client gitignore.mustache with shards related files (OpenAPITools#10698) Adds ComposedSchema to store schema composed schemas (OpenAPITools#10653) Adds setPrettyPrint and the reslver MethodValueResolver.INSTANCE (OpenAPITools#10683) [dart] Fix pub server URL (OpenAPITools#10695) ...
The unused imports don't pass stricter TS compiler settings.
Tested by using the modified template as an override in project.
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.For Windows users, please run the script in Git BASH.
master(5.3.0),6.0.x