OpenAPITools / OpenAPITools/openapi-generator

[BUG][typescript-angular] generated README has invalid instructions

Open
#14,971 1 comment 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)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When I generate a client with the typescript-angular generator, the generated code has a README.md which starts with

To install the required dependencies and to build the typescript sources run:

  npm install
  npm run build

However running npm install fails with no such file or directory, open '/path/to/generated/directory/package.json'

Indeed, the generated code does not have a package.json
(not sure if the issue is that the generated code should have a package.json or if the README should have other instructions)

openapi-generator version

Observed with 6.3.0 and reproduced with a jar built with the latest master

OpenAPI declaration file content or url

I think the content of the openapi file does not matter. However, here is a simple one with which I observe that issue:

openapi: 3.0.1
info:
  title: Test
  version: 0.0.1
paths:
  /my-route:
    get:
      summary: Get stuff
      parameters:
        - name: myparam
          in: query
          required: false
          schema:
            type: string
            format: date-time
      responses:
        "200":
          description: OK
Generation Details

generate with

java -jar openapi-generator-cli.jar generate -g typescript-angular -i openapi.yaml -o out
Steps to reproduce

after generating the typescript-angular code with the above command:

cd out                     # go to the generated directory
head README.md # look at the first instructions of the README
npm install              # run the first command found in the README

expected behavior: the command succeeds
observed behavior: the command complains that it is looking for an unexpected package.json

(nb: I observe that issue with npm 9.5.0 on Ubuntu)

Related issues/PRs

I haven't found any related issues on https://github.com/OpenAPITools/openapi-generator/issues?q=is%3Aissue+is%3Aopen+angular+README

Suggest a fix

I guess a package.json should be generated (or the README should be updated)

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

Start by reproducing the stated Java CLI generation command for the typescript-angular generator, then inspect the generated README.md and directory contents. Trace why the README instructs npm install when package.json is absent. Done means the generated output and its README agree, with the documented first command succeeding.

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.