Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • O openapi-generator
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 3,476
    • Issues 3,476
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 402
    • Merge requests 402
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • OpenAPI Tools
  • openapi-generator
  • Merge requests
  • !13810

[FIX][typescript-axios] Fix missing imports when using allOf composition

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Administrator requested to merge github/fork/Digirik/fix/typescript-axios-model-with-allOf-composition into master 2 years ago
  • Overview 3
  • Commits 4
  • Pipelines 0
  • Changes 7

Created by: Digirik

This PR will fix Issue #13809.

With this commit the generation of imports for allOf compositions without discriminator has been disabled for all langauges except python & plain js. This is problematic/causes issues with some generated specs.

In this PR the new addImport method of the commit mentioned earlier is overriden in the TypeScriptAxiosClientCodegen.java to ensure previous behavior. If the change mentioned earlier is a problem for the other typescript generators as well the fix should probably be moved to the AbstractTypeScriptClientCodegen .

To validate the work use ./bin/generate-samples.sh bin/configs/typescript-axios-with-separate-models-and-api-inheritance.yaml once with and once without the fix and compare the files it generates.

@TiFu @taxpon @sebastianhaas @kenisteward @Vrolijkx @macjohnny @topce @akehir @petejohansonxo @amakhrov @davidgamero @mkusaka

PR checklist

  • Read the contribution guidelines.
  • Pull Request title clearly describes the work in the pull request and Pull Request description provides details about how to validate the work. Missing information here may result in delayed response from the community.
  • Run the following to build the project and update samples:
    ./mvnw clean package 
    ./bin/generate-samples.sh
    ./bin/utils/export_docs_generators.sh
    Commit all changed files. This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master. These must match the expectations made by your contribution. You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example ./bin/generate-samples.sh bin/configs/java*. For Windows users, please run the script in Git BASH.
  • File the PR against the correct branch: master (6.1.0) (minor release - breaking changes with fallbacks), 7.0.x (breaking changes without fallbacks)
  • If your PR is targeting a particular programming language, @mention the technical committee members, so they are more likely to review the pull request.
Compare
  • master (base)

and
  • latest version
    84270d32
    4 commits, 2 years ago

7 files
+ 216
- 0

    Preferences

    File browser
    Compare changes
modules/openap‎i-generator/src‎
main/java/org/…/‎codegen/languages‎
TypeScriptAxiosC‎lientCodegen.java‎ +7 -0
test/resources/3_‎0/typescript-axios‎
with-separate-models-a‎nd-api-inheritance.yaml‎ +60 -0
samples‎/…/…/…/…‎
.openapi-‎generator‎
FI‎LES‎ +3 -0
mo‎del‎
abstract-flat-stock-p‎ick-order-base-dto.ts‎ +78 -0
flat-stock-pick-o‎rder-dto-all-of.ts‎ +36 -0
flat-stock-pic‎k-order-dto.ts‎ +29 -0
inde‎x.ts‎ +3 -0
modules/openapi-generator/src/main/java/org/openapitools/codegen/languages/TypeScriptAxiosClientCodegen.java
+ 7
- 0
  • View file @ 84270d32

  • Edit in single-file editor

  • Open in Web IDE


@@ -17,6 +17,7 @@
package org.openapitools.codegen.languages;
import io.swagger.v3.oas.models.media.ComposedSchema;
import io.swagger.v3.oas.models.media.Schema;
import io.swagger.v3.parser.util.SchemaTypeUtil;
import org.apache.commons.lang3.StringUtils;
@@ -287,4 +288,10 @@ public class TypeScriptAxiosClientCodegen extends AbstractTypeScriptClientCodege
updatePropertyForMap(property, p);
}
}
@Override
protected void addImport(ComposedSchema composed, Schema childSchema, CodegenModel model, String modelName) {
// import everything (including child schema of a composed schema)
addImport(model, modelName);
}
}
modules/openapi-generator/src/test/resources/3_0/typescript-axios/with-separate-models-and-api-inheritance.yaml
+ 60
- 0
  • View file @ 84270d32

  • Edit in single-file editor

  • Open in Web IDE


@@ -33,3 +33,63 @@ components:
type: object
allOf:
- "$ref": "#/components/schemas/AbstractUserDto"
AbstractFlatStockPickOrderBaseDto:
required:
- externalDmsCustomerOrderId
- id
- partInformation
- pickedQuantity
- quantity
- type
- warehouseId
type: object
properties:
id:
type: integer
format: int64
created:
type: string
format: date-time
lastModified:
type: string
format: date-time
warehouseId:
type: integer
format: int64
quantity:
type: number
stockLocation:
maxLength: 31
minLength: 0
type: string
barcode:
maxLength: 31
minLength: 1
type: string
pickedQuantity:
type: number
type:
type: string
discriminator:
propertyName: type
mapping:
STOCK_PICK_ORDER: '#/components/schemas/FlatStockPickOrderDto'
FlatStockPickOrderDto:
required:
- externalDmsCustomerOrderId
- id
- partInformation
- pickedQuantity
- quantity
- warehouseId
type: object
allOf:
- $ref: '#/components/schemas/AbstractFlatStockPickOrderBaseDto'
- type: object
properties:
blockedUntil:
type: string
format: date-time
blockedById:
type: integer
format: int64
samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/.openapi-generator/FILES
+ 3
- 0
  • View file @ 84270d32

  • Edit in single-file editor

  • Open in Web IDE


@@ -6,8 +6,11 @@ common.ts
configuration.ts
git_push.sh
index.ts
model/abstract-flat-stock-pick-order-base-dto.ts
model/abstract-user-dto.ts
model/branch-dto.ts
model/flat-stock-pick-order-dto-all-of.ts
model/flat-stock-pick-order-dto.ts
model/index.ts
model/internal-authenticated-user-dto.ts
model/remote-authenticated-user-dto.ts
samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/abstract-flat-stock-pick-order-base-dto.ts 0 → 100644
+ 78
- 0
  • View file @ 84270d32

  • Edit in single-file editor

  • Open in Web IDE

/* tslint:disable */
/* eslint-disable */
/**
* Example
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface AbstractFlatStockPickOrderBaseDto
*/
export interface AbstractFlatStockPickOrderBaseDto {
/**
*
* @type {number}
* @memberof AbstractFlatStockPickOrderBaseDto
*/
'id': number;
/**
*
* @type {string}
* @memberof AbstractFlatStockPickOrderBaseDto
*/
'created'?: string;
/**
*
* @type {string}
* @memberof AbstractFlatStockPickOrderBaseDto
*/
'lastModified'?: string;
/**
*
* @type {number}
* @memberof AbstractFlatStockPickOrderBaseDto
*/
'warehouseId': number;
/**
*
* @type {number}
* @memberof AbstractFlatStockPickOrderBaseDto
*/
'quantity': number;
/**
*
* @type {string}
* @memberof AbstractFlatStockPickOrderBaseDto
*/
'stockLocation'?: string;
/**
*
* @type {string}
* @memberof AbstractFlatStockPickOrderBaseDto
*/
'barcode'?: string;
/**
*
* @type {number}
* @memberof AbstractFlatStockPickOrderBaseDto
*/
'pickedQuantity': number;
/**
*
* @type {string}
* @memberof AbstractFlatStockPickOrderBaseDto
*/
'type': string;
}
samples/client/others/typescript-axios/with-separate-models-and-api-inheritance/model/flat-stock-pick-order-dto-all-of.ts 0 → 100644
+ 36
- 0
  • View file @ 84270d32

  • Edit in single-file editor

  • Open in Web IDE

/* tslint:disable */
/* eslint-disable */
/**
* Example
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document: 1
*
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
* https://openapi-generator.tech
* Do not edit the class manually.
*/
/**
*
* @export
* @interface FlatStockPickOrderDtoAllOf
*/
export interface FlatStockPickOrderDtoAllOf {
/**
*
* @type {string}
* @memberof FlatStockPickOrderDtoAllOf
*/
'blockedUntil'?: string;
/**
*
* @type {number}
* @memberof FlatStockPickOrderDtoAllOf
*/
'blockedById'?: number;
}
0 Assignees
None
Assign to
0 Reviewers
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
Lock merge request
Unlocked
participants
Reference:
Source branch: github/fork/Digirik/fix/typescript-axios-model-with-allOf-composition