swagger-api / swagger-api/swagger-codegen
typescript-fetch generated code BaseAPI class doesn't compile
Nobody has claimed this yet.
- Dominant language
- Mustache
- Stars
- 17.8k
- Forks
- 6k
- PR merge metrics
- No merged PRs in 30d
Description
Description
The generated BaseAPI has a non-nullable field Configuration, but it is conditionally assigned in the constructor, resulting in a TS2564 Property 'configuration' has no initializer and is not definitely assigned in the constructor.
Also, in the RequiredError below, the value name has the same issue. It seems to use a semicolon instead of an = symbol
Swagger-codegen version
2.3.1 using version 1.0.44 parser (due to the bundled parser not following refs correctly as has been detailed on another issue)
Swagger declaration file content or url
Any yaml produces it, but here's an abridged version for referenced
If you post the code inline, please wrap it with
swagger: "2.0"
info:
description: API for VK
version: "1.0.0"
title: Blah
tags:
- name: Miscellaneous
description: A collection of endpoints for miscellaneous technical tasks
paths:
'/actuator/health':
get:
tags:
- Miscellaneous
produces:
- application/json
responses:
200:
description: Service is health
503:
description: Service is unavailable
schemes:
- http
Command line used for generation
maven plugin
Steps to reproduce
maven install, then try and use a typescript compiler or see the generated output
Related issues/PRs
Nope
Suggest a fix/enhancement
Within the following file: https://github.com/swagger-api/swagger-codegen/blob/master/modules/swagger-codegen/src/main/resources/typescript-fetch/api.mustache,
Either make configuration nullable , or provide a default one.
Change the colon to an equals in RequiredError.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with modules/swagger-codegen/src/main/resources/typescript-fetch/api.mustache and reproduce the issue with maven install. Inspect the generated BaseAPI and RequiredError output, then compile the generated TypeScript to verify both reported errors are resolved.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 35/100