{"action":"opened","issue":{"url":"https://api.github.com/repos/SkeLLLa/fastify-oas/issues/1","repository_url":"https://api.github.com/repos/SkeLLLa/fastify-oas","labels_url":"https://api.github.com/repos/SkeLLLa/fastify-oas/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/SkeLLLa/fastify-oas/issues/1/comments","events_url":"https://api.github.com/repos/SkeLLLa/fastify-oas/issues/1/events","html_url":"https://github.com/SkeLLLa/fastify-oas/issues/1","id":378593908,"node_id":"MDU6SXNzdWUzNzg1OTM5MDg=","number":1,"title":"Multiple types not supported","user":{"login":"bneigher","id":4627728,"node_id":"MDQ6VXNlcjQ2Mjc3Mjg=","avatar_url":"https://avatars1.githubusercontent.com/u/4627728?v=4","gravatar_id":"","url":"https://api.github.com/users/bneigher","html_url":"https://github.com/bneigher","followers_url":"https://api.github.com/users/bneigher/followers","following_url":"https://api.github.com/users/bneigher/following{/other_user}","gists_url":"https://api.github.com/users/bneigher/gists{/gist_id}","starred_url":"https://api.github.com/users/bneigher/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bneigher/subscriptions","organizations_url":"https://api.github.com/users/bneigher/orgs","repos_url":"https://api.github.com/users/bneigher/repos","events_url":"https://api.github.com/users/bneigher/events{/privacy}","received_events_url":"https://api.github.com/users/bneigher/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-11-08T06:18:38Z","updated_at":"2018-11-08T06:18:38Z","closed_at":null,"author_association":"NONE","body":"Awesome library!  I have completely autogenerated docs thanks to this repo 💪 \r\n\r\nOne thing I believe I have stumbled across is that you can't have multiple types e.g:\r\n\r\n> Note: `SwaggerHelper.modelToSwaggerProps` is just a method that maps Sequelize model datatypes to Swagger datatypes\r\n\r\n```\r\nconst {ProjectUsers, Projects} = require('my-sequelize-model-repo')\r\n\r\nfastify.addSchema({\r\n  $id: 'projectUser',\r\n  type: 'object',\r\n  properties: Object.assign(\r\n    SwaggerHelper.modelToSwaggerProps(ProjectUsers, true)[ProjectUser],\r\n    {\r\n      Project: {\r\n        type: ['object', 'null'],\r\n        nullable: true,\r\n        properties: SwaggerHelper.modelToSwaggerProps(Projects)[Project]\r\n      }\r\n    }\r\n  )\r\n})\r\n```\r\nWhich will generate...\r\n```\r\n{\r\n '$id': 'projectUser',\r\n  type: 'object',\r\n  properties: {\r\n     id: { type: 'integer' },\r\n     user_id: { type: 'integer' },\r\n     project_id: { type: 'integer' },\r\n     notes: { type: 'string' },\r\n     occurred_at: { type: 'string', format: 'date-time' },\r\n     created_at: { type: 'string', format: 'date-time' },\r\n     updated_at: { type: 'string', format: 'date-time' },\r\n     deleted_at: { type: 'string', format: 'date-time' },\r\n     Project: {\r\n         type: ['object', 'null'],\r\n         nullable: true,\r\n         properties: {\r\n            id: { type: 'integer' },\r\n            name: { type: 'string' }\r\n         }\r\n     }\r\n  }\r\n}\r\n```\r\nNote the attempt to get the child association (Project) to be either an `object` or `null`\r\n\r\nI think this was also caught in another implementation: https://github.com/AfterShip/swagger-ajv/issues/19\r\n\r\nThis has got me in quite the pickle because Ajv (the default json validator with fastify) isn't happy with if the Project model is null if I just keep the type as 'object'.  This configuration works in the API response through Ajv - but it breaks in swagger docs\r\n\r\n![image](https://user-images.githubusercontent.com/4627728/48180979-8fe99d00-e2da-11e8-8983-3485bbe24a27.png)\r\n\r\n![image](https://user-images.githubusercontent.com/4627728/48181045-d2ab7500-e2da-11e8-91c6-8e3b89b379df.png)\r\n"}}
{"actor":{"display_login":"bneigher"}}