diff --git a/aspida.config.js b/aspida.config.js index 8d41c3a5..b9f7fcdb 100644 --- a/aspida.config.js +++ b/aspida.config.js @@ -38,10 +38,5 @@ module.exports = [ input: 'samples/array-one-of', outputEachDir: true, openapi: { inputFile: 'samples/array-one-of.yml' } - }, - { - input: 'samples/path-at-mark', - outputEachDir: true, - openapi: { inputFile: 'samples/path-at-mark.yml', replaceLeadingAtMark: '' } } ] diff --git a/src/buildTemplate.ts b/src/buildTemplate.ts index 2ff94b4b..a9138b30 100644 --- a/src/buildTemplate.ts +++ b/src/buildTemplate.ts @@ -6,14 +6,11 @@ import { Config } from './getConfig' const isV3 = (openapi: OpenAPI.Document): openapi is OpenAPIV3.Document => 'openapi' in openapi -export default async ({ input, isYaml, replaceLeadingAtMark }: Config) => { +export default async ({ input, isYaml }: Config) => { const openapi = await parse(input, { parse: { json: !isYaml } }) const docs = isV3(openapi) ? openapi : await require('swagger2openapi').convertObj(openapi, { direct: true }) - return buildV3( - await resolveExternalRefs(docs, typeof input === 'string' ? input : ''), - replaceLeadingAtMark - ) + return buildV3(await resolveExternalRefs(docs, typeof input === 'string' ? input : '')) } diff --git a/src/buildV3.ts b/src/buildV3.ts index 30b38cb7..b45bd345 100644 --- a/src/buildV3.ts +++ b/src/buildV3.ts @@ -25,7 +25,7 @@ const getParamsList = ( params?: (OpenAPIV3.ReferenceObject | OpenAPIV3.ParameterObject)[] ) => params?.map(p => (isRefObject(p) ? resolveParamsRef(openapi, p.$ref) : p)) || [] -export default (openapi: OpenAPIV3.Document, replaceLeadingAtMark: string) => { +export default (openapi: OpenAPIV3.Document) => { const files: { file: string[]; methods: string }[] = [] const schemas = schemas2Props(openapi.components?.schemas, openapi) || [] const parameters = parameters2Props(openapi.components?.parameters, openapi, false) || [] @@ -56,8 +56,7 @@ export default (openapi: OpenAPIV3.Document, replaceLeadingAtMark: string) => { [] as OpenAPIV3.ParameterObject[] ) ], - false, - replaceLeadingAtMark + false ) ), 'index' diff --git a/src/builderUtils/getDirName.ts b/src/builderUtils/getDirName.ts index 971ad0dc..30ec741a 100644 --- a/src/builderUtils/getDirName.ts +++ b/src/builderUtils/getDirName.ts @@ -1,16 +1,9 @@ import { OpenAPIV3 } from 'openapi-types' import { getPropertyName, schema2value } from './converters' -export default ( - text: string, - params: OpenAPIV3.ParameterObject[], - required: boolean, - replaceLeadingAtMark: string -) => { +export default (text: string, params: OpenAPIV3.ParameterObject[], required: boolean) => { if (text === '*') return '_any' if (!/^{/.test(text)) { - if (replaceLeadingAtMark !== '@' && text.startsWith('@')) - return text.replace('@', replaceLeadingAtMark) return text } diff --git a/src/getConfig.ts b/src/getConfig.ts index 30a6dd13..1e294c3c 100644 --- a/src/getConfig.ts +++ b/src/getConfig.ts @@ -5,14 +5,12 @@ export type Config = Pick { trailingSlash: config.trailingSlash, outputEachDir: config.outputEachDir, outputMode: config.outputMode, - isYaml: openapi.yaml ?? !openapi.inputFile.endsWith('.json'), - replaceLeadingAtMark: openapi.replaceLeadingAtMark ?? '@' + isYaml: openapi.yaml ?? !openapi.inputFile.endsWith('.json') } }