|
|
@ -1,5 +1,5 @@ |
|
|
import { VOLO_NAME_VALUE, VOLO_REGEX } from '../constants'; |
|
|
import { VOLO_NAME_VALUE, VOLO_REGEX } from '../constants'; |
|
|
import { Interface, Model, Property, Type, TypeWithEnum } from '../models'; |
|
|
import { Interface, Model, Property, PropertyDef, Type, TypeWithEnum } from '../models'; |
|
|
import { parseNamespace } from './namespace'; |
|
|
import { parseNamespace } from './namespace'; |
|
|
import { relativePathToModel } from './path'; |
|
|
import { relativePathToModel } from './path'; |
|
|
import { camel } from './text'; |
|
|
import { camel } from './text'; |
|
|
@ -119,7 +119,7 @@ export function createImportRefToInterfaceReducerCreator(params: ModelGeneratorP |
|
|
|
|
|
|
|
|
typeDef.properties?.forEach(prop => { |
|
|
typeDef.properties?.forEach(prop => { |
|
|
const name = camel(prop.name); |
|
|
const name = camel(prop.name); |
|
|
const optional = prop.typeSimple.endsWith('?') ? '?' : ''; |
|
|
const optional = isOptionalProperty(prop) ? '?' : ''; |
|
|
const type = simplifyType(prop.typeSimple); |
|
|
const type = simplifyType(prop.typeSimple); |
|
|
const refs = parseType(prop.type).reduce( |
|
|
const refs = parseType(prop.type).reduce( |
|
|
(acc: string[], r) => acc.concat(parseGenerics(r).toGenerics()), |
|
|
(acc: string[], r) => acc.concat(parseGenerics(r).toGenerics()), |
|
|
@ -150,3 +150,9 @@ export function createRefToImportReducerCreator(params: ModelGeneratorParams) { |
|
|
const { solution } = params; |
|
|
const { solution } = params; |
|
|
return (namespace: string) => createTypesToImportsReducer(solution, namespace); |
|
|
return (namespace: string) => createTypesToImportsReducer(solution, namespace); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function isOptionalProperty(prop: PropertyDef) { |
|
|
|
|
|
return ( |
|
|
|
|
|
prop.typeSimple.endsWith('?') || (prop.typeSimple === 'string' && prop.isRequired === false) |
|
|
|
|
|
); |
|
|
|
|
|
} |
|
|
|