question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG][typescript-axios] The generated ts file from 5.0.0 cannot be transpiled.

See original GitHub issue

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

The generation works fine with the 5.0.0-beta2. When switching to the stable version 5.0.0, the generated code has some compilation errors: TS2339: Property 'isJsonMime' does not exist on type 'Configuration'.

openapi-generator version

5.0.0

OpenAPI declaration file content or url
---
openapi: 3.0.0
info:
  title: Swagger Test Service
  description: Test Service for OpenApi version 2 aka. Swagger as YAML file.
  version: 1.0.0
paths:
  "/entities/{pathParam}":
    parameters:
    - in: path
      name: pathParam
      required: true
      schema:
        type: string
    post:
      summary: Test POST
      operationId: postEntity
      description: Test POST
      parameters:
      - in: query
        name: queryParam
        schema:
          type: string
      responses:
        '200':
          description: Success
          content:
            application/json:
              schema:
                type: array
                minItems: 0
                items:
                  "$ref": "#/components/schemas/TestEntity"
      tags:
      - default
    patch:
      summary: Test PATCH
      operationId: patchEntity
      requestBody:
        content:
          application/json:
            schema:
              "$ref": "#/components/schemas/TestEntity"
      responses:
        '200':
          description: Success
      tags:
      - default
components:
  schemas:
    TestEntity:
      type: object
      properties:
        stringProperty:
          type: string
          description: A string property
        integerProperty:
          type: integer
          description: An integer property
tags:
- name: default
Generation Details

npx openapi-generator-cli generate --input-spec /input-dir/open-api.json --generator-name typescript-axios --output /output-dir/openapi --template-dir /template-dir/templates --api-package api --model-package model --additional-properties withSeparateModelsAndApi=true --skip-validate-spec

Steps to reproduce
  1. Generate the client by using the command and the spec file above.
  2. Transpile the generated code and see TS2339: Property 'isJsonMime' does not exist on type 'Configuration'.
Suggest a fix

Make isJsonMime as an optional function of the type Configuration.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

5reactions
denodaeuscommented, May 4, 2021

This works, but honestly, it makes for a really not-nice API:

Before:

const API = new TradeblottersApi({
        // TODO: for some reason swagger client removes port from requests if you don't specify the "basePath"
        basePath: 'http://localhost:3000',
        baseOptions: {
            withCredentials: true,
        },
    });

Now:

const API = new TradeblottersApi(
    new Configuration({
        // TODO: for some reason swagger client removes port from requests if you don't specify the "basePath"
        basePath: 'http://localhost:3000',
        baseOptions: {
            withCredentials: true,
        },
    }),
);
0reactions
jjtang1985commented, Jan 29, 2021

Hi @macjohnny , I resolve the issue by updating the configuration template from the 5.0.0. Thank you for taking care.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I import/reference/require a transpiled TypeScript file?
I have created a myLib.min.js / myLib.d.ts file combination from my TypeScript project using AMD module type, ES5 target and TypeScript 1.8 --outFile ......
Read more >
@rollup/plugin-babel - npm
A Rollup plugin for seamless integration between Rollup and Babel. Why? If you're using Babel to transpile your ES6/7 code and Rollup to ......
Read more >
Experimenting With ts-node And Using TypeScript In Node.js ...
This means that all TypeScript files should be loaded and transpiled before you have a chance to bind your HTTP server to a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found