{"action":"opened","issue":{"url":"https://api.github.com/repos/TypeStrong/typedoc/issues/930","repository_url":"https://api.github.com/repos/TypeStrong/typedoc","labels_url":"https://api.github.com/repos/TypeStrong/typedoc/issues/930/labels{/name}","comments_url":"https://api.github.com/repos/TypeStrong/typedoc/issues/930/comments","events_url":"https://api.github.com/repos/TypeStrong/typedoc/issues/930/events","html_url":"https://github.com/TypeStrong/typedoc/issues/930","id":394453175,"node_id":"MDU6SXNzdWUzOTQ0NTMxNzU=","number":930,"title":"Serializer plugin not working as expected","user":{"login":"tilersmyth","id":8736328,"node_id":"MDQ6VXNlcjg3MzYzMjg=","avatar_url":"https://avatars2.githubusercontent.com/u/8736328?v=4","gravatar_id":"","url":"https://api.github.com/users/tilersmyth","html_url":"https://github.com/tilersmyth","followers_url":"https://api.github.com/users/tilersmyth/followers","following_url":"https://api.github.com/users/tilersmyth/following{/other_user}","gists_url":"https://api.github.com/users/tilersmyth/gists{/gist_id}","starred_url":"https://api.github.com/users/tilersmyth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tilersmyth/subscriptions","organizations_url":"https://api.github.com/users/tilersmyth/orgs","repos_url":"https://api.github.com/users/tilersmyth/repos","events_url":"https://api.github.com/users/tilersmyth/events{/privacy}","received_events_url":"https://api.github.com/users/tilersmyth/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-12-27T17:48:08Z","updated_at":"2018-12-27T17:48:08Z","closed_at":null,"author_association":"NONE","body":"I could be approaching this incorrectly, but I have been tirelessly trying to get this to work to no avail. My aim is to add a custom key/value to the generateJson output schema. I started by adding the key to the reflection using a converter plugin on the Converter.EVENT_CREATE_DECLARATION event. See below for simplified version: \r\n```\r\ndeclare class decReflection extends Reflection {\r\n  test: string;\r\n}\r\n\r\n@Component({ name: \"test-plugin\" })\r\nexport class TestPlugin extends ConverterComponent {\r\n \r\n\r\n  initialize() {\r\n    this.listenTo(this.owner, {\r\n      [Converter.EVENT_CREATE_DECLARATION]: this.onDeclaration,\r\n    });\r\n  }\r\n\r\n  private onDeclaration(\r\n    context: Context,\r\n    reflection: decReflection,\r\n    node?: any\r\n  ) {\r\n    if (!node) {\r\n      return;\r\n    }\r\n\r\n    reflection.test = 'test value';\r\n  }\r\n}\r\n```\r\n\r\nIt wasn't until I noticed that the output did not contain my custom key/value that, by process of elimination, I narrowed the problem down to serialization, which (apparently) determines the output schema. \r\n\r\nI feel like I am doing everything correctly when creating the serialization plugin, starting with adding the component. It seems as though for whatever reason the `support` function is not getting processed as it is advertised in the /lib/serialization/components.ts file. \r\n\r\n> Like [[Converter]] plugins each [[Serializer]] plugin defines a predicate that instructs if an\r\n> object can be serialized by it, this is done dynamically at runtime via a `supports` method.\r\n\r\nSo here is my attempt at getting the serializer plugin to work, starting with the index file which adds the component: \r\n\r\n```\r\nmodule.exports = function(PluginHost: any) {\r\n  var app = PluginHost.owner;\r\n\r\n  app.converter.addComponent(\"test-plugin\", TestPlugin);\r\n  app.serializer.addComponent(\"serializer:test-plugin\", TestPluginSerializer);\r\n};\r\n```\r\n\r\nthen the serializer plugin class: \r\n\r\n```\r\n@Component({ name: \"serializer:test-plugin\" })\r\nexport class TestPluginSerializer extends SerializerComponent<TestReflection> {\r\n  static PRIORITY = 1000;\r\n\r\n  serializeGroup = (instance: unknown): boolean => {\r\n    return instance instanceof TestReflection;\r\n  };\r\n\r\n  supports = (t: unknown) => {\r\n    return true;\r\n  };\r\n\r\n  serializeGroupSymbol = Comment;\r\n\r\n  toObject(testReflection: TestReflection, obj?: any): any {\r\n    obj = obj || {};\r\n\r\n    if (testReflection.test) {\r\n      obj.test = testReflection.test;\r\n    }\r\n\r\n    return obj;\r\n  }\r\n}\r\n```\r\n\r\nAfter much digging, I can see that the serializer gets added as a component but for whatever reason the support function is not called. \r\n\r\nAgain, I am simply trying to add a key/value to the json schema generated by the generateJson method. I could be approaching this completely wrong, but if the serializer plugin is required then it is a lot less intuitive than it needs to be or something is buggy.\r\n\r\nAny insight/help would be appreciated!\r\n"}}
{"actor":{"display_login":"tilersmyth"}}