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] Missing type #7887

Open
4 tasks done
Eywek opened this issue Nov 5, 2020 · 0 comments
Open
4 tasks done

[BUG] [Typescript] Missing type #7887

Eywek opened this issue Nov 5, 2020 · 0 comments

Comments

@Eywek
Copy link

Eywek commented Nov 5, 2020

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?
Description

See examples below

openapi-generator version

From v4.3.0 to 5.0.0-SNAPSHOT

OpenAPI declaration file content or url
openapi: 3.0.0
info:
    title: datasources-v2-frontend
    version: 0.0.0
paths:
    '/{id}':
        patch:
            parameters:
                -
                    name: id
                    in: path
                    schema:
                        type: string
                    required: true
            responses:
                '200':
                    description: Ok
                    content:
                        application/json:
                            schema:
                                type: object
                                properties:
                                    data: {type: object, properties: {}}
                                required:
                                    - data
            tags:
                - Datasource
            requestBody:
                required: true
                content:
                    application/json:
                        schema:
                            $ref: '#/components/schemas/Partial_WorkerDatasourceVersion__'
            operationId: update-datasource
components:
    schemas:
        ApiOptions_:
            type: object
            properties:
                oauth:
                    type: string
                method:
                    oneOf:
                        -
                            type: string
                            enum:
                                - GET
                        -
                            type: string
                            enum:
                                - PATCH
                        -
                            type: string
                            enum:
                                - POST
                        -
                            type: string
                            enum:
                                - PUT
                body:
                    type: string
                headers:
                    type: object
                    properties: {}
                    additionalProperties:
                        type: string
                query:
                    type: object
                    properties: {}
                    additionalProperties:
                        type: string
                pagination:
                    oneOf:
                        -
                            type: object
                            properties:
                                type:
                                    type: string
                                    enum: [query]
                                value:
                                    type: string
                            required:
                                - type
                                - value
                        -
                            type: object
                            properties:
                                type:
                                    type: string
                                    enum: [hypermediaAttribute]
                                value:
                                    type: string
                            required:
                                - type
                                - value
        ApiOptions:
            $ref: '#/components/schemas/ApiOptions_'
        Partial_WorkerDatasourceVersion__:
            type: object
            properties:
                companyId:
                    type: string
                resourceGroupIds:
                    type: array
                    items:
                        type: string
                name:
                    type: string
                apiOptions:
                    $ref: '#/components/schemas/ApiOptions'
Generation Details
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v4.3.0 generate \
            --additional-properties=useSingleRequestParameter=true,enumPropertyNaming=UPPERCASE \
            -i /local/swagger.yaml \
            -g typescript-axios \
            -o /local/client

Generated typescript:

/**
 * 
 * @export
 * @interface PartialWorkerDatasourceVersion
 */
export interface PartialWorkerDatasourceVersion {
    /**
     * 
     * @type {string}
     * @memberof PartialWorkerDatasourceVersion
     */
    companyId?: string;
    /**
     * 
     * @type {Array<string>}
     * @memberof PartialWorkerDatasourceVersion
     */
    resourceGroupIds?: Array<string>;
    /**
     * 
     * @type {string}
     * @memberof PartialWorkerDatasourceVersion
     */
    name?: string;
    /**
     * 
     * @type {ApiOptions}
     * @memberof PartialWorkerDatasourceVersion
     */
    apiOptions?: ApiOptions;
}

The type ApiOptions is never defined. Probably because the ApiOptions ref to ApiOptions with an underscore and the underscore gets removed by the generator leading to this bug.

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