-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(core): remove duplicate imports generated by swagger-typescript (#…
…502)
- Loading branch information
1 parent
22b4159
commit 0fc17d4
Showing
4 changed files
with
83 additions
and
19 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
packages/core/src/generators/swagger-typescript/__snapshots__/generator.spec.ts.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`swagger-typescript generator should run successfully for OpenAPI 3.0: libs/generated-ts/src/index.ts 1`] = ` | ||
"export * from './interfaces/company'; | ||
export * from './interfaces/person'; | ||
export * from './interfaces/temperature'; | ||
export * from './interfaces/weather-forecast'; | ||
" | ||
`; | ||
|
||
exports[`swagger-typescript generator should run successfully for OpenAPI 3.0: libs/generated-ts/src/interfaces/company.ts 1`] = ` | ||
"import { Person } from './person'; | ||
export interface Company { | ||
CEO?: Person | ||
employees?: Person[] | ||
} | ||
" | ||
`; | ||
|
||
exports[`swagger-typescript generator should run successfully for OpenAPI 3.0: libs/generated-ts/src/interfaces/person.ts 1`] = ` | ||
"import { Company } from './company'; | ||
export interface Person { | ||
employer?: Company | ||
} | ||
" | ||
`; | ||
|
||
exports[`swagger-typescript generator should run successfully for OpenAPI 3.0: libs/generated-ts/src/interfaces/temperature.ts 1`] = ` | ||
" | ||
export interface Temperature { | ||
temperatureC: number | ||
temperatureF: number | ||
} | ||
" | ||
`; | ||
|
||
exports[`swagger-typescript generator should run successfully for OpenAPI 3.0: libs/generated-ts/src/interfaces/weather-forecast.ts 1`] = ` | ||
"import { Temperature } from './temperature'; | ||
import { Person } from './person'; | ||
export interface WeatherForecast { | ||
date: string | ||
temperature?: Temperature | ||
summary?: string | ||
forecaster?: Person | ||
} | ||
" | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 8 additions & 8 deletions
16
...re/src/generators/swagger-typescript/templates/interface/__interfaceFileName__.ts__tmpl__
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,13 @@ | ||
<% if (necessaryImports) for (const i of necessaryImports) { -%> | ||
import {<%=i.className%>} from './<%=i.fileName%>'; | ||
<% } %> | ||
<% if (necessaryImports) for (const [, i] of necessaryImports) { -%> | ||
import { <%=i.className%> } from './<%=i.fileName%>'; | ||
<% } -%> | ||
|
||
<% if (tsInterface.type === 'interface') { %> | ||
<% if (tsInterface.type === 'interface') { -%> | ||
export interface <%= interfaceClassName %> { | ||
<% for (const property of tsInterface.properties) {-%> | ||
<%_ for (const property of tsInterface.properties) {-%> | ||
<%= property.name %><% if (property.nullable) { %>?<%}%>: <%= property.type %> | ||
<% } %> | ||
<%_ } -%> | ||
} | ||
<% } else if (tsInterface.type === 'array') {%> | ||
<% } else if (tsInterface.type === 'array') { -%> | ||
export type <%= interfaceClassName %> = <%= tsInterface.elements %>[] | ||
<% } %> | ||
<% } -%> |