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 in the construction of routes #5

Closed
Mague opened this issue Apr 13, 2019 · 7 comments
Closed

Error in the construction of routes #5

Mague opened this issue Apr 13, 2019 · 7 comments
Assignees

Comments

@Mague
Copy link

Mague commented Apr 13, 2019

Hello, when using the library I found that adding the library in a project a little more advanced than the basic example for all the requests showed me an error not found, the .yaml file that I use will generate it with editor.swagger.io, the routes when I define them I place / at the beginning as in the examples that I found since I am testing openapi and I have no experience with it, and I am testing what is the difference with respect to documentation with apidoc and I found it interesting about the validation from the own documentation. Anyway, I drifted away from the topic, try moving :
new OpenApiValidator ({ apiSpecPath: spec, }). install (app)

since I assumed that it is a middleware and in effect with that I got to show the path that serves static files that I use to serve the documentation generated with apidoc, inspecting the variables I realized that the library start of each route places // instead of / and that makes the routes are not achieved, the solution I got was to replace the line 43 const openApiRoute = `$ {bp} $ {path}`; of the file dis / openapi.spec.loader.js
as it is a temporary solution I write to you to verify, I get lost in the logic of typescript. In my project I use a dynamic load of urls, I do not know if that is the cause of the error. Thank you and apologize if you do not understand well I do not speak English and use the translator

@Mague
Copy link
Author

Mague commented Apr 13, 2019

I forgot what I used to fix it
const openApiRoute = (path[0] == "/") ? ${path}:${bp}${path}${path};

@cdimascio
Copy link
Owner

Thanks for the ticket @Mague. I will have a look.

@cdimascio
Copy link
Owner

cdimascio commented Apr 20, 2019

@Mague i've delivered a fix. see version 0.21.2. please give it a try.
The fix is more careful about the trailing slash when composing the api path with the openapi base path

@cdimascio cdimascio self-assigned this Apr 20, 2019
@cdimascio
Copy link
Owner

cdimascio commented Apr 20, 2019

id be interested to see your openapi spec if your able to paste its contents here

@Mague
Copy link
Author

Mague commented Apr 21, 2019

Hello, I already installed that version and if it worked correctly. How do I share my specification file?

@Mague
Copy link
Author

Mague commented Apr 21, 2019

`
openapi: 3.0.1
info:
title: Lol
description: >-
Welcome
Enmanuel Molina
contact:
email: lol@gmail.com
license:
name: Apache 2.0
url: 'http://www.apache.org/licenses/LICENSE-2.0.html'
version: 1.0.0
servers:

  • url: 'http://localhost:3000'
    tags:

  • name: auth
    description: Autentifica los datos de un usuario y genera token de acceso
    paths:
    /auth/signin:
    post:
    summary: ''
    description: Autentifica los datos de un usuario y genera token de acceso
    operationId: logIn
    requestBody:
    description: Objeto de usuario necesario para logear
    content:
    application/json:
    schema:
    $ref: '#/components/schemas/Auth'
    required: true
    responses:
    "200":
    description: Default error sample response
    content:
    application/json:
    schema:
    $ref: '#/components/schemas/User'
    "401":
    description: Usuario o contraseña incorrectos
    content: {}
    default:
    description: unexpected error
    content:
    application/json:
    schema:
    $ref: "#/components/schemas/Error"
    tags:
    - auth
    components:
    schemas:
    Auth:
    required:
    - userName
    - pwd
    type: object
    properties:
    userName:
    type: string
    example: "admin"
    pwd:
    type: string
    example: "superman"
    xml:
    name: Auth
    User:
    type: object
    properties:
    status:
    type: boolean
    example: true
    id:
    type: integer
    example: 1
    name:
    type: string
    example: "Enmanuel Molina"
    email:
    type: string
    example: "enmanueldavidmolina@gmail.com"
    phone:
    type: string
    example: '+584267257288'
    xml:
    name: User
    NewAttribute:
    required:
    - name
    properties:
    name:
    type: string

    Attribute:
    allOf:
    - $ref: "#/components/schemas/NewAttribute"
    - required:
    - id
    properties:
    id:
    type: integer
    format: int64
    Error:
    required:
    - code
    - message
    properties:
    code:
    type: integer
    format: int32
    message:
    type: string

`

@cdimascio
Copy link
Owner

Thanks @Mague

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

2 participants