@@ -58,9 +58,10 @@ const primitiveSchemaTypes = [
5858 * if any function processed the input, remaining ones will skip
5959 * @param fns functions in the pipeline
6060 */
61- const pipe = (
62- ...fns : Array < ( pipelineValue : PipelineValue ) => PipelineValue >
63- ) => ( x : PipelineValue ) => fns . reduce ( ( v , f ) => ( ! v . isHandled ? f ( v ) : v ) , x ) ;
61+ const pipe =
62+ ( ...fns : Array < ( pipelineValue : PipelineValue ) => PipelineValue > ) =>
63+ ( x : PipelineValue ) =>
64+ fns . reduce ( ( v , f ) => ( ! v . isHandled ? f ( v ) : v ) , x ) ;
6465
6566export type ModelProperties = { [ propertyName : string ] : Mapper | string [ ] } ;
6667
@@ -91,12 +92,12 @@ export async function transformMappers(
9192 return [ ] ;
9293 }
9394
94- const uberParentsNames = uberParents . map ( up => up . name ) ;
95+ const uberParentsNames = uberParents . map ( ( up ) => up . name ) ;
9596 const hasXmlMetadata = mediaTypes ?. has ( KnownMediaType . Xml ) ;
9697 return [
9798 ...codeModel . schemas . objects ,
9899 ...extractHeaders ( codeModel . operationGroups , clientName )
99- ] . map ( objectSchema =>
100+ ] . map ( ( objectSchema ) =>
100101 transformMapper ( {
101102 schema : objectSchema ,
102103 options : {
@@ -275,13 +276,17 @@ function getXmlMetadata(
275276
276277 const defaultName =
277278 serializedName || getLanguageMetadata ( schema . language ) . serializedName ;
278- const { name, attribute : xmlIsAttribute , wrapped : xmlIsWrapped } =
279- schema . serialization ?. xml || { } ;
279+ const {
280+ name,
281+ attribute : xmlIsAttribute ,
282+ wrapped : xmlIsWrapped
283+ } = schema . serialization ?. xml || { } ;
280284
281285 const xmlName = name || defaultName ;
282286
283- const headerCollectionPrefix = getLanguageMetadata ( schema . language )
284- . headerCollectionPrefix ;
287+ const headerCollectionPrefix = getLanguageMetadata (
288+ schema . language
289+ ) . headerCollectionPrefix ;
285290
286291 return {
287292 ...( headerCollectionPrefix && { headerCollectionPrefix } ) ,
@@ -330,8 +335,8 @@ function transformObjectMapper(pipelineValue: PipelineValue) {
330335 true /** immediateOnly */
331336 ) ;
332337 const parentsRefs = immediateParents
333- . map ( p => getMapperClassName ( p ) )
334- . filter ( p => p !== className ) ;
338+ . map ( ( p ) => getMapperClassName ( p ) )
339+ . filter ( ( p ) => p !== className ) ;
335340
336341 const additionalProperties = buildAdditionalProperties ( objectSchema ) ;
337342
@@ -350,12 +355,20 @@ function transformObjectMapper(pipelineValue: PipelineValue) {
350355 // If any of the parents is present in uberParents we know it
351356 // is its uber parent
352357 let uberParent = getMapperClassName (
353- parents . find ( p => uberParents . includes ( getMapperClassName ( p ) ) ) || schema
358+ parents . find (
359+ ( p ) =>
360+ ( p as ObjectSchema ) . discriminator &&
361+ uberParents . includes ( getMapperClassName ( p ) )
362+ ) ||
363+ parents . find ( ( p ) => uberParents . includes ( getMapperClassName ( p ) ) ) ||
364+ schema
354365 ) ;
355366
356367 if ( objectSchema . parents ?. immediate [ 0 ] ) {
357368 uberParent = getMapperClassName (
358- objectSchema . parents ?. immediate [ 0 ] as ObjectSchema
369+ objectSchema . parents ?. immediate . find (
370+ ( im ) => ( im as ObjectSchema ) . discriminator
371+ ) || ( objectSchema . parents ?. immediate [ 0 ] as ObjectSchema )
359372 ) ;
360373 }
361374 const mapper = buildMapper (
@@ -527,7 +540,7 @@ function transformChoiceMapper(pipelineValue: PipelineValue) {
527540 } else {
528541 type = {
529542 name : MapperType . Enum ,
530- allowedValues : choiceSchema . choices . map ( choice => choice . value )
543+ allowedValues : choiceSchema . choices . map ( ( choice ) => choice . value )
531544 } ;
532545 }
533546 }
@@ -703,7 +716,7 @@ function processProperties(
703716 options : EntityOptions = { }
704717) {
705718 let modelProperties : ModelProperties = { } ;
706- properties . forEach ( prop => {
719+ properties . forEach ( ( prop ) => {
707720 const serializedName = getPropertySerializedName ( prop ) ;
708721 const propName = getLanguageMetadata ( prop . language ) . name ;
709722 const name = normalizeName (
@@ -734,9 +747,9 @@ function getPropertySerializedName({
734747 }
735748
736749 return flattenedNames
737- . map ( name => {
750+ . map ( ( name ) => {
738751 // Escaping names
739- [ "." ] . forEach ( character => {
752+ [ "." ] . forEach ( ( character ) => {
740753 name = name . replace ( character , `\\${ character } ` ) ;
741754 } ) ;
742755 return name ;
0 commit comments