Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG][typescript-fetch] withInterfaces result includes 'raw' methods #10237

Open
deroude opened this issue Aug 23, 2021 · 0 comments
Open

[BUG][typescript-fetch] withInterfaces result includes 'raw' methods #10237

deroude opened this issue Aug 23, 2021 · 0 comments

Comments

@deroude
Copy link

deroude commented Aug 23, 2021

Description

When I generate typescript-fetch code from OpenAPI spec, using withInterfaces=true switch, the generated interfaces include two methods for each API operation, e.g. getArticles and getArticlesRaw.

The raw method is not part of the API, it's an implementation detail; the interface should be 1:1 with the OpenAPI spec.

openapi-generator version

"@openapitools/openapi-generator-cli": "^2.3.7"

OpenAPI declaration file content or url
openapi: 3.0.1
info:
  title: Example
  description: Reproducing bug
  version: 1.0.0
servers:
  - url: 'http://localhost:9000/'
tags:
  - name: article
    description: 'Everything concerning articles, comments'
paths:
  /article:
    get:
      tags:
        - article
      summary: Get all articles
      operationId: getArticles
      parameters:
        - in: query
          name: category
          schema:
            type: string
            default: BLOG
        - in: query
          name: filter
          schema:
            type: string
        - in: query
          name: language
          schema:
            type: string
            default: en
        - in: query
          name: page
          schema:
            type: integer
            default: 0
        - in: query
          name: itemsPerPage
          schema:
            type: integer
            default: 20
      responses:
        '200':
          description: Articles retrieved
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/Article'      
components:
  schemas:
    Article:
      type: object
      properties:
        id:
          type: string
          format: uuid
        author:
          $ref: '#/components/schemas/User'
        category:
          type: string
          description: Category
          enum:
            - BLOG
            - FRONT_PAGE
        title:
          type: string
          description: Title
        slug:
          type: string
        text:
          type: string
        tags:
          type: string
        language:
          type: string
        publishDate:
          type: string
          format: date-time
          description: Published Date    
Generation Details
openapi-generator-cli generate -g typescript-fetch -i api-bundle.yaml -o ./packages/generated --additional-properties=typescriptThreePlus=true,withInterfaces=true
Steps to reproduce

Generate code from provided spec using provided script.
Check generated/apis/ArticleApi.ts

Suggest a fix

The method is written here -- either remove this completely, or make it ? optional.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant