Skip to content

Commit

Permalink
Fix empty nested serializers error
Browse files Browse the repository at this point in the history
  • Loading branch information
skryukov committed Nov 8, 2024
1 parent 358dea0 commit 3535a3b
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/typelizer/dsl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def assign_type_information(attribute_name, attributes)

unless respond_to?(attribute_name)
define_singleton_method(attribute_name) do
result = instance_variable_get(instance_variable)
result = instance_variable_get(instance_variable) || {}
if superclass.respond_to?(attribute_name)
result.merge(superclass.send(attribute_name))
else
Expand Down
14 changes: 14 additions & 0 deletions spec/__snapshots__/AlbaUserEmptyNested.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Typelizer digest 1002a651beda81fd3d91636e80542552
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {AlbaPost} from '@/types'

type AlbaUserEmptyNested = {
id: number;
username: string | null;
posts?: Array<AlbaPost>;
avatar: unknown;
typed_avatar: string | null;
}

export default AlbaUserEmptyNested;
14 changes: 14 additions & 0 deletions spec/__snapshots__/AmsUserEmptyNested.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Typelizer digest 8c962041f6d8142284309a7a7695ccff
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {AmsPost} from '@/types'

type AmsUserEmptyNested = {
id: number;
username: string | null;
avatar: unknown;
typed_avatar: string | null;
posts?: Array<AmsPost>;
}

export default AmsUserEmptyNested;
14 changes: 14 additions & 0 deletions spec/__snapshots__/OjSerializersUserEmptyNested.ts.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
// Typelizer digest 792747cc9a6687f61568633186ee265d
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
import type {OjSerializersPost} from '@/types'

type OjSerializersUserEmptyNested = {
id: number;
username: string | null;
posts?: Array<OjSerializersPost>;
avatar: unknown;
typed_avatar: string | null;
}

export default OjSerializersUserEmptyNested;
5 changes: 4 additions & 1 deletion spec/__snapshots__/index.ts.snap
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Typelizer digest b30b67423d9475d4fb19db422c52a55f
// Typelizer digest 22ff4b5bc8af67e16ccf03d2d3b8aad2
//
// DO NOT MODIFY: This file was automatically generated by Typelizer.
export type { default as AlbaInline } from './AlbaInline'
Expand All @@ -7,17 +7,20 @@ export type { default as AlbaMeta } from './AlbaMeta'
export type { default as AlbaPoro } from './AlbaPoro'
export type { default as AlbaPost } from './AlbaPost'
export type { default as AlbaUserAuthor } from './AlbaUserAuthor'
export type { default as AlbaUserEmptyNested } from './AlbaUserEmptyNested'
export type { default as AlbaUser } from './AlbaUser'
export type { default as AlbaUserSerializerFoo } from './AlbaUserSerializerFoo'
export type { AlbaVerbatimModuleSyntax } from './AlbaVerbatimModuleSyntax'
export type { default as AmsPost } from './AmsPost'
export type { default as AmsUserAuthor } from './AmsUserAuthor'
export type { default as AmsUserEmptyNested } from './AmsUserEmptyNested'
export type { default as AmsUser } from './AmsUser'
export type { default as AmsUserSerializerFoo } from './AmsUserSerializerFoo'
export type { AmsVerbatimModuleSyntax } from './AmsVerbatimModuleSyntax'
export type { default as OjSerializersFlatUser } from './OjSerializersFlatUser'
export type { default as OjSerializersPost } from './OjSerializersPost'
export type { default as OjSerializersUserAuthor } from './OjSerializersUserAuthor'
export type { default as OjSerializersUserEmptyNested } from './OjSerializersUserEmptyNested'
export type { default as OjSerializersUser } from './OjSerializersUser'
export type { default as OjSerializersUserSerializerFoo } from './OjSerializersUserSerializerFoo'
export type { OjSerializersVerbatimModuleSyntax } from './OjSerializersVerbatimModuleSyntax'
6 changes: 6 additions & 0 deletions spec/app/app/serializers/alba/user/empty_nested_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Alba
module User
class EmptyNestedSerializer < AuthorSerializer
end
end
end
6 changes: 6 additions & 0 deletions spec/app/app/serializers/ams/user/empty_nested_serializer.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module Ams
module User
class EmptyNestedSerializer < AuthorSerializer
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module OjSerializers
module User
class EmptyNestedSerializer < AuthorSerializer
end
end
end

0 comments on commit 3535a3b

Please sign in to comment.