Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

400
Views
aws cdk: sirva swagger ui con puerta de enlace api

Quiero usar AWS ApiGateway para servir una swagger-ui de una API desde una función lambda usando express. Para esto, quiero usar el punto final GET /docs . Mi función Lambda swaggerUiLambdaHandler se ve así:

 import express from 'express'; import serverless from 'serverless-http'; import swaggerUI from 'swagger-ui-express'; const options = { swaggerOptions: { url: 'https://petstore.swagger.io/v2/swagger.json', }, }; const app = express(); app.use('/v1/docs', swaggerUI.serve, swaggerUI.setup(undefined, options)); module.exports.handler = serverless(app);

En la pila de cdk de la API, agregué los siguientes 2 puntos finales para servir los recursos index.html y .js/.css:

 const docs = myApi.root.addResource('docs'); docs.addMethod('GET', new apigw.LambdaIntegration(swaggerUiLambdaHandler)); const docsProxy = docs.addResource('{proxy+}'); docsProxy.addMethod('GET', new apigw.LambdaIntegration(swaggerUiLambdaHandler));

Sin embargo, al llamar al punto final con el navegador, todas las solicitudes de red tienen éxito, pero aparece un lienzo en blanco y el error

 Uncaught SyntaxError: Unexpected token '<'

¿Tienes alguna idea? Creo que podría estar relacionado con el content-type devuelto por la puerta de enlace api, pero agradecería algo de ayuda.

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!