0
0
Expressframework~10 mins

Swagger UI integration in Express - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to import the Swagger UI middleware.

Express
const swaggerUi = require('[1]');
Drag options to blanks, or click blank then click option'
Aswagger-ui-express
Bexpress-swagger-ui
Cswagger-ui
Dswagger-ui-middleware
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'swagger-ui' which is the UI only, not the Express middleware.
Confusing with 'express-swagger-ui' which is a different package.
2fill in blank
medium

Complete the code to serve Swagger UI at the '/api-docs' route.

Express
app.use('/api-docs', swaggerUi.[1](swaggerDocument));
Drag options to blanks, or click blank then click option'
Aserve
Bsetup
CserveFiles
Dinit
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'serve' which is a middleware but not the setup function.
Using 'init' which does not exist in this context.
3fill in blank
hard

Fix the error in the Swagger document import statement.

Express
const swaggerDocument = require('./[1].json');
Drag options to blanks, or click blank then click option'
Aswagger-ui
BswaggerDoc
CswaggerDocument
Dswagger
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'swaggerDocument' as file name which is a variable name, not a file.
Using 'swagger-ui' which is a package name, not a file.
4fill in blank
hard

Fill both blanks to correctly import Express and create an app instance.

Express
const [1] = require('express');
const app = [2]();
Drag options to blanks, or click blank then click option'
Aexpress
Bapp
Cexpress()
DexpressApp
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'app' as the import variable name which is usually reserved for the app instance.
Using 'express()' as the import variable which is a function call, not a variable.
5fill in blank
hard

Fill all three blanks to correctly set up Swagger UI middleware with options.

Express
app.use('/api-docs', swaggerUi.[1](swaggerDocument, [2]));

const options = [3];
Drag options to blanks, or click blank then click option'
Asetup
B{ explorer: true }
Coptions
D{ swaggerOptions: { persistAuthorization: true } }
Attempts:
3 left
💡 Hint
Common Mistakes
Passing the options object inline instead of as a variable.
Using 'serve' instead of 'setup' for the method.