@@ -137,15 +137,10 @@ function schemaToOpenAPI(
137137 * This function will return the field value parsed as the type of the schema. i.e. if the schema is a number, it will return the field as a JS number.
138138 *
139139 * @param schema A schema object
140- * @param field The target field to parse in that schema
140+ * @param fieldValue The value to parse
141141 * @returns the parsed value
142142 */
143- const parseField = ( schema : Schema , field : string ) : any => {
144- const fieldValue = getTagName ( schema , field ) ;
145- if ( ! fieldValue ) {
146- return ;
147- }
148-
143+ const parseField = ( schema : Schema , fieldValue : string ) : any => {
149144 if ( schema . type === 'number' || schema . type === 'integer' ) {
150145 return Number ( fieldValue ) ;
151146 } else if ( schema . type === 'boolean' ) {
@@ -181,10 +176,10 @@ function schemaToOpenAPI(
181176 const description = schema . comment ?. description ;
182177
183178 const defaultOpenAPIObject = {
184- ...( defaultValue ? { default : parseField ( schema , 'default' ) } : { } ) ,
179+ ...( defaultValue ? { default : parseField ( schema , defaultValue ) } : { } ) ,
185180 ...( deprecated ? { deprecated : true } : { } ) ,
186181 ...( description ? { description } : { } ) ,
187- ...( example ? { example : parseField ( schema , ' example' ) } : { } ) ,
182+ ...( example ? { example : parseField ( schema , example ) } : { } ) ,
188183 ...( maxLength ? { maxLength : Number ( maxLength ) } : { } ) ,
189184 ...( minLength ? { minLength : Number ( minLength ) } : { } ) ,
190185 ...( pattern ? { pattern } : { } ) ,
0 commit comments