@@ -8,6 +8,7 @@ const { xResponseDescription, xConsume, xExamples } = require('../../constants')
88const { rawRequired } = require ( '../../symbols' )
99const { generateParamsSchema } = require ( '../../util/generate-params-schema' )
1010const { hasParams } = require ( '../../util/match-params' )
11+ const { CUSTOM_HEADER } = require ( '../constants' )
1112
1213function prepareDefaultOptions ( opts ) {
1314 const openapi = opts . openapi
@@ -26,7 +27,7 @@ function prepareDefaultOptions (opts) {
2627 const convertConstToEnum = opts . convertConstToEnum
2728
2829 for ( const [ key , value ] of Object . entries ( opts . openapi ) ) {
29- if ( key . startsWith ( 'x-' ) ) {
30+ if ( key . startsWith ( CUSTOM_HEADER ) ) {
3031 extensions . push ( [ key , value ] )
3132 }
3233 }
@@ -82,7 +83,7 @@ function prepareOpenapiObject (opts) {
8283function normalizeUrl ( url , serverUrls , stripBasePath ) {
8384 if ( ! stripBasePath ) return formatParamUrl ( url )
8485 serverUrls . forEach ( function ( serverUrl ) {
85- const basePath = serverUrl . startsWith ( '/' ) ? serverUrl : new URL ( serverUrl ) . pathname
86+ const basePath = serverUrl [ 0 ] === '/' ? serverUrl : new URL ( serverUrl ) . pathname
8687 if ( url . startsWith ( basePath ) && basePath !== '/' ) {
8788 url = url . replace ( basePath , '' )
8889 }
@@ -489,7 +490,7 @@ function prepareOpenapiMethod (opts, schema, ref, openapiObject, url) {
489490 if ( schema . servers ) openapiMethod . servers = schema . servers
490491 if ( schema . callbacks ) openapiMethod . callbacks = resolveCallbacks ( opts , schema . callbacks , ref )
491492 for ( const key of Object . keys ( schema ) ) {
492- if ( key . startsWith ( 'x-' ) ) {
493+ if ( key . startsWith ( CUSTOM_HEADER ) ) {
493494 openapiMethod [ key ] = schema [ key ]
494495 }
495496 }
0 commit comments