OpenAPITools / OpenAPITools/openapi-generator

[BUG] typescript-angular variables.ts should not be used if supportingFiles are disabled

Open
#4,282 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Bug Report Checklist
  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

Running the generator with -D models,apis skips generating supportingFiles, but the generated service uses the missing variables.ts (part of supportingFiles).

openapi-generator version

4.1.3

OpenAPI declaration file content or url
openapi: 3.0.0
info:
  title: Deployed APIs
  version: 1.0.0
servers:
- url: http://localhost:8181
- url: https://localhost:8543
paths:
  /api/hello/{name}:
    get:
      description: Say hello to someone
      operationId: sayHello
      parameters:
      - name: name
        in: path
        description: name
        required: true
        schema:
          type: string
      responses:
        200:
          description: Ok
          content:
            '*/*':
              schema:
                $ref: '#/components/schemas/HelloObject'
  /api/hello:
    get:
      description: Say hello world
      operationId: sayHelloWorld
      responses:
        200:
          description: Ok
components:
  schemas:
    HelloObject:
      type: object
      properties:
        message:
          type: string
Command line used for generation

openapi-generator generate -i http://localhost:8181/openapi/ -g typescript-angular -o src/lib/model -D models,apis --additional-properties='stringEnums=true,fileNaming=kebab-case'

Steps to reproduce

Run the generator with given command line and try to build the project.

excerpt of generated file:

import { BASE_PATH, COLLECTION_FORMATS }                     from '../variables';
import { Configuration }                                     from '../configuration';


@Injectable({
  providedIn: 'root'
})
export class DefaultService {
Suggest a fix

Merge the configuration and variables into one file or do not use them.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Inspect the typescript-angular generator's supportingFiles handling and the generated variables.ts and configuration imports; reproduce the issue with the shown command and OpenAPI example while disabling supportingFiles. Done when a models/apis-only generation no longer references missing supporting files and the generated project builds.

Written by the indexing model from the issue text.

Assessment

Tech stack
angular, typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.