ad-on-is / adonis-autoswagger

Auto-Generate swagger docs for AdonisJS
MIT License
122 stars 39 forks source link

String literal union type - Resolver error at components.schemas.<MyClass>.properties.<MyProperty>.$ref #118

Open nick-infinitegiving opened 2 months ago

nick-infinitegiving commented 2 months ago

Ran into this error below and was wondering if anyone has a recommendation how to proceed? -Thx

@column()
// @enum(pending, active, deleted)
public status: 'pending' | 'active' | 'deleted'

Resolver error at components.schemas..properties..$ref Could not resolve reference: Could not resolve pointer: /components/schemas/'pending' does not exist in document

Fails with and without the enum tag.

Ovoda commented 2 months ago

I know it's not ideal but have you tried the following ?

@column()
// @enum(pending, active, deleted)
public status: string
nick-infinitegiving commented 2 months ago

Hi @Ovoda - Yes we did however our goal was to maintain the typing. We did hack it in so that if a property is tagged as an enum it automatically sets the type in the definition to string. Thank you for the suggestion!