Skip to content

Convert the example to ESM to use TLA #192

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

Merged
merged 1 commit into from
Dec 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,13 @@ See [Fastify's LTS policy](https://github.com/fastify/fastify/blob/main/docs/Ref
Add it with `@fastify/swagger` to your project with `register`, pass it some options, call the `swagger` API, and you are done!

```js
const fastify = require('fastify')()
import fastify from 'fastify'

await fastify.register(require('@fastify/swagger'))
const app = fastify()

await fastify.register(require('@fastify/swagger-ui'), {
await app.register(import('@fastify/swagger'))

await app.register(import('@fastify/swagger-ui'), {
routePrefix: '/documentation',
uiConfig: {
docExpansion: 'full',
Expand All @@ -52,7 +54,7 @@ await fastify.register(require('@fastify/swagger-ui'), {
transformSpecificationClone: true
})

fastify.put('/some-route/:id', {
app.put('/some-route/:id', {
schema: {
description: 'post some data',
tags: ['user', 'code'],
Expand Down Expand Up @@ -102,7 +104,7 @@ fastify.put('/some-route/:id', {
}
}, (req, reply) => {})

await fastify.ready()
await app.ready()
```
<a name="api"></a>
## API
Expand Down
Loading