Skip to content

Commit a07a00f

Browse files
authored
Merge pull request #185 from LumaKernel/revert-atmark
revert: replaceLeadingAtMark of PR #146
2 parents 52db3c8 + a03b993 commit a07a00f

File tree

5 files changed

+6
-25
lines changed

5 files changed

+6
-25
lines changed

aspida.config.js

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,5 @@ module.exports = [
3838
input: 'samples/array-one-of',
3939
outputEachDir: true,
4040
openapi: { inputFile: 'samples/array-one-of.yml' }
41-
},
42-
{
43-
input: 'samples/path-at-mark',
44-
outputEachDir: true,
45-
openapi: { inputFile: 'samples/path-at-mark.yml', replaceLeadingAtMark: '' }
4641
}
4742
]

src/buildTemplate.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,11 @@ import { Config } from './getConfig'
66

77
const isV3 = (openapi: OpenAPI.Document): openapi is OpenAPIV3.Document => 'openapi' in openapi
88

9-
export default async ({ input, isYaml, replaceLeadingAtMark }: Config) => {
9+
export default async ({ input, isYaml }: Config) => {
1010
const openapi = await parse(input, { parse: { json: !isYaml } })
1111
const docs = isV3(openapi)
1212
? openapi
1313
: await require('swagger2openapi').convertObj(openapi, { direct: true })
1414

15-
return buildV3(
16-
await resolveExternalRefs(docs, typeof input === 'string' ? input : ''),
17-
replaceLeadingAtMark
18-
)
15+
return buildV3(await resolveExternalRefs(docs, typeof input === 'string' ? input : ''))
1916
}

src/buildV3.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const getParamsList = (
2525
params?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[]
2626
) => params?.map(p => (isRefObject(p) ? resolveParamsRef(openapi, p.$ref) : p)) || []
2727

28-
export default (openapi: OpenAPIV3.Document, replaceLeadingAtMark: string) => {
28+
export default (openapi: OpenAPIV3.Document) => {
2929
const files: { file: string[]; methods: string }[] = []
3030
const schemas = schemas2Props(openapi.components?.schemas, openapi) || []
3131
const parameters = parameters2Props(openapi.components?.parameters, openapi, false) || []
@@ -56,8 +56,7 @@ export default (openapi: OpenAPIV3.Document, replaceLeadingAtMark: string) => {
5656
[] as OpenAPIV3.ParameterObject[]
5757
)
5858
],
59-
false,
60-
replaceLeadingAtMark
59+
false
6160
)
6261
),
6362
'index'

src/builderUtils/getDirName.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,9 @@
11
import { OpenAPIV3 } from 'openapi-types'
22
import { getPropertyName, schema2value } from './converters'
33

4-
export default (
5-
text: string,
6-
params: OpenAPIV3.ParameterObject[],
7-
required: boolean,
8-
replaceLeadingAtMark: string
9-
) => {
4+
export default (text: string, params: OpenAPIV3.ParameterObject[], required: boolean) => {
105
if (text === '*') return '_any'
116
if (!/^{/.test(text)) {
12-
if (replaceLeadingAtMark !== '@' && text.startsWith('@'))
13-
return text.replace('@', replaceLeadingAtMark)
147
return text
158
}
169

src/getConfig.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@ export type Config = Pick<AspidaConfig, 'outputEachDir' | 'outputMode' | 'traili
55
input: string | OpenAPI.Document
66
output: string
77
isYaml: boolean
8-
replaceLeadingAtMark: string
98
}
109

1110
export type ConfigFile = AspidaConfig & {
1211
openapi?: {
1312
inputFile: string
1413
yaml?: boolean
15-
replaceLeadingAtMark?: string
1614
outputDir?: string
1715
}
1816
}
@@ -25,8 +23,7 @@ const createConfig = (config: ConfigFile): Config => {
2523
trailingSlash: config.trailingSlash,
2624
outputEachDir: config.outputEachDir,
2725
outputMode: config.outputMode,
28-
isYaml: openapi.yaml ?? !openapi.inputFile.endsWith('.json'),
29-
replaceLeadingAtMark: openapi.replaceLeadingAtMark ?? '@'
26+
isYaml: openapi.yaml ?? !openapi.inputFile.endsWith('.json')
3027
}
3128
}
3229

0 commit comments

Comments
 (0)