0

I am perplexed by my Swagger YAML file here that I am 99% sure is correct, but obviously it is not, but not sure where the issue could be:

/**
* @openapi
* components:
*   schemas:
*     ViewMedicationDto:
*       type: array
*       items:
*         type: object
*         properties:
*           _type:
*             type: string
*           id:
*             type: string
*           pui:
*             type: string
*           medicationType:
*             type: string
*           tradeName:
*             type: string
*           medicationTags: []
*           createdOn:
*             type: string
*           updatedOn:
*             type: string
*         example:
*           - _type: ViewMedicationDto
*           id: 61ae82c8f95692912cc423ed
*           pui: test_danielcortes_821205_59909
*           medicationType: Rescue
*           tradeName: Accolate
*           medicationTags: [ [Object], [Object] ]
*           createdOn: 2021-12-06T21:38:16.359Z
*           updatedOn: 2021-12-06T21:38:16.359Z
*/
export class ViewMedicationDto implements DtoInterface {
readonly _type = 'ViewMedicationDto';

readonly id: ID
readonly pui: string

readonly medicationType: MedicationType
readonly tradeName: string

readonly medicationTags?: ITag[]

readonly createdOn?: Date
readonly updatedOn?: Date

constructor(id: ID, pui: string,
medicationType: MedicationType, tradeName: string,
medicationTags?: ITag[],
createdOn?: Date, updatedOn?: Date) {
this.id = id
this.pui = pui

this.medicationType = medicationType
this.tradeName = tradeName

this.medicationTags = medicationTags

this.createdOn = createdOn
this.updatedOn = updatedOn
}

}

I am thinking it's that medicationTags the issue, but when I remove it, it does not render still.

Update

I attempted to follow the solution below like so:

/**
* @openapi
* components:
*   schemas:
*     ViewMedicationDto:
*       type: array
*       items:
*         type: object
*         properties:
*           _type:
*             type: string
*           id:
*             type: string
*           pui:
*             type: string
*           medicationType:
*             type: string
*           tradeName:
*             type: string
*           medicationTags:
*             type: array
*             items:
*               type: object
*           createdOn:
*             type: string
*           updatedOn:
*             type: string
*         example:
*           _type: ViewMedicationDto
*           id: 61ae82c8f95692912cc423ed
*           pui: test_danielcortes_821205_59909
*           medicationType: Rescue
*           tradeName: Accolate
*           medicationTags: [{}, {}]
*           createdOn: 2021-12-06T21:38:16.359Z
*           updatedOn: 2021-12-06T21:38:16.359Z
*/
halfer
  • 19,824
  • 17
  • 99
  • 186
Daniel
  • 14,004
  • 16
  • 96
  • 156

1 Answers1

0

You are right that one issue is the medicationTags syntax. Another issue is the example syntax.

Try this:

*     ViewMedicationDto:
*       type: array
*       items:
*         type: object
*         properties:
*           ...
*           medicationTags:
*             type: array
*             items:
*               type: object   # Assuming that ITag is an object
*           createdOn:
*             type: string
*           updatedOn:
*             type: string
*         example:
*           _type: ViewMedicationDto     # <--- No leading dash here
*           id: 61ae82c8f95692912cc423ed
*           pui: test_danielcortes_821205_59909
*           medicationType: Rescue
*           tradeName: Accolate
*           medicationTags: [ {}, {} ]   # <--- TODO: add a proper ITag JSON array example
*           createdOn: 2021-12-06T21:38:16.359Z
*           updatedOn: 2021-12-06T21:38:16.359Z
Helen
  • 87,344
  • 17
  • 243
  • 314
  • can you view my UPDATE, I followed your solution and it is still not rendering. – Daniel Dec 06 '21 at 23:20
  • The problem might be elsewhere. When you open Swagger UI, are there any errors on the Console tab of the browser dev tools? If you [export OpenAPI YAML](https://stackoverflow.com/q/48525546/113116) from Swagger UI and paste it into https://editor.swagger.io, does it report any errors? – Helen Dec 07 '21 at 07:32
  • I can possibly do this if I push it first to staging server. Right now its on local. – Daniel Dec 07 '21 at 17:49