Closed im4aLL closed 5 months ago
Hmmm... There seems to be an issue with nesting I didn't account for. Will see what I can do.
Extended IFs are not supported yet.
I just saw you are returning a paginated response... there is already a helper for that <Model[]>.paginated()
<Model[]>.paginated()
It doesn't do anything
Yeah, I gave pagination response for example. What I tried to say is, if I extend or if it is a nested interface, it doesn't work
Are you on the newest version? and did you use an existing model like <User[]>.paginated()
Yes, new version AdonisJS 6 and new version of adonis-autoswagger. Yes, I am using existing model <ExistingModel[]>.paginated()
Would you post your code with the comment decorators?
index method of product controller
/**
* @index
* @description It also accepts filters by "name"
* @responseBody 200 - <Product[]>.paginated()
* @paramUse(pagination)
*/
async index({ request }: HttpContext) {
const page = request.input(GLOBAL_CONFIG.pagination.param, 1)
const limit = GLOBAL_CONFIG.pagination.limit
const model = Product.query()
// filter
const filterName = request.input('name')
if (filterName && filterName.length > 0) {
model.withScopes((scopes) => scopes.search(filterName))
}
const products = await model.orderBy('created_at', 'desc').paginate(page, limit)
return products.toJSON()
}
swagger config
import path from 'node:path'
import url from 'node:url'
export default {
path: path.dirname(url.fileURLToPath(import.meta.url)) + '/../',
title: 'Rest API',
version: '1.0.0',
tagIndex: 3,
snakeCase: true,
debug: false, // set to true, to get some useful debug output
ignore: ['/swagger', '/docs'],
preferredPutPatch: 'PUT', // if PUT/PATCH are provided for the same route, prefer PUT
common: {
parameters: {
pagination: [
{
in: 'query',
name: 'page',
schema: { type: 'string', example: '1' },
},
],
}, // OpenAPI conform parameters that are commonly used
headers: {}, // OpenAPI conform headers that are commonly used
},
persistAuthorization: true, // persist authorization between reloads on the swagger page
showFullPath: false, // the path displayed after endpoint summary
}
This is what it looks like at my end, when using the exact same decorators. and parameters
This is what it looks like on my end
BTW, which UI is that you posted?
its rapidoc, but shouldn't make a difference
Are you sure, you're on the newest version of autoswagger? what version shows in your package.json.
"adonis-autoswagger": "^3.6.0"
"adonis-autoswagger": "^3.6.0"
this is waaaaaay behind... we're on 3.16.0 now
alright, pagination seems working now.
However, the extended interface still not working (just checking whether it works for you), but only in the request body, the nested interface is working.
I haven't looked into this one yet. well keep you posted once it's done
Fixed in 3.17.0
If we define
GenericPaginationResponseInterface
in swagger it shows like this
is that an issue or I am doing something wrong? Also, I noticed that, if I extend an interface it doesn't work as well.