Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on accessing localhost:3333/swagger #102

Open
GilTRipper opened this issue Jun 22, 2024 · 5 comments
Open

Error on accessing localhost:3333/swagger #102

GilTRipper opened this issue Jun 22, 2024 · 5 comments

Comments

@GilTRipper
Copy link

GilTRipper commented Jun 22, 2024

Here im using example from readme to access docs vida /docs route

/*
|--------------------------------------------------------------------------
| Routes file
|--------------------------------------------------------------------------
|
| The routes file is used for defining the HTTP routes.
|
*/

import '#routes/api'

import AutoSwagger from 'adonis-autoswagger'
import swagger from '#config/swagger'
import router from '@adonisjs/core/services/router'

// returns swagger in YAML
router.get('/swagger', async () => {
  // console.log(router.toJSON())
  return AutoSwagger.default.docs(router.toJSON(), swagger)
})

// Renders Swagger-UI and passes YAML-output of /swagger
router.get('/docs', async () => {
  return AutoSwagger.default.ui('/swagger', swagger)
  // return AutoSwagger.default.scalar("/swagger", swagger); to use Scalar instead
  // return AutoSwagger.default.rapidoc("/swagger", swagger); to use RapiDoc instead
})

but when i'm trying to reach localhost:3333/docs got this issue
Node .../backend/app/validators/auth.ts does not exist

my validators/auth.ts

import vine from '@vinejs/vine'
import { ExtractSchemaType } from './types.js'

export const createAccountValidator = vine.compile(
  vine.object({
    username: vine.string().trim().minLength(5).maxLength(32),
    email: vine.string().email(),
    password: vine.string().minLength(8).maxLength(32),
  })
)

export const loginValidator = vine.compile(
  vine.object({
    username: vine.string(),
    password: vine.string(),
  })
)

export type CreateAccountData = ExtractSchemaType<typeof createAccountValidator>
export type LoginData = ExtractSchemaType<typeof loginValidator>

the strange is that when i'm using node ace docs:generate everything is fine

"adonis-autoswagger": "^3.47.0",

@CostierLucas
Copy link

I encountered the same error initially. However, it's peculiar because after sending a POST request from my client to the backend, the Swagger documentation was displayed correctly and the error disappeared. But when I restart my server, the error reappears

@ad-on-is
Copy link
Owner

I encountered the same error initially. However, it's peculiar because after sending a POST request from my client to the backend, the Swagger documentation was displayed correctly and the error disappeared. But when I restart my server, the error reappears

whuuuut?

could someone create a reproducable adonisjs project and upload it to github?

@CostierLucas
Copy link

CostierLucas commented Jun 26, 2024

#98 (comment)

it's pretty much the same error, it says that the validator file doesn't exist when it already does

@ad-on-is
Copy link
Owner

I just found out!
This is an issue with node ace serve --hmr
Using node ace serve --watch however, works as expected. If someone knows how to solve it, I'd appreciate it.

@ad-on-is
Copy link
Owner

ad-on-is commented Jun 27, 2024

For now, I've added a warning message, so it's at least clear what's going on, until the issue is somehow fixed.

Edit: I contacted the developer of hot-hook, to see whether it's an upstream issue, or an issue with AutoSwagger. Julien-R44/hot-hook#9

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants