|
| 1 | +--- |
| 2 | +title: Introducing support for Scalar - Elysia |
| 3 | +sidebar: false |
| 4 | +editLink: false |
| 5 | +search: false |
| 6 | +head: |
| 7 | + - - meta |
| 8 | + - property: 'og:title' |
| 9 | + content: Introducing support for Scalar - Elysia |
| 10 | + |
| 11 | + - - meta |
| 12 | + - name: 'description' |
| 13 | + content: We are changing API documentation provider to Scalar instead of Swagger UI by default. Scalar is a modern, beautiful API references for OpenAPI compatible, and customizable built on-top of Vue. Elysia now ship @elysia/swagger package by using Scalar as a default provider, with option to switch back to Swagger UI if need. |
| 14 | + |
| 15 | + - - meta |
| 16 | + - property: 'og:description' |
| 17 | + content: We are changing API documentation provider to Scalar instead of Swagger UI by default. Scalar is a modern, beautiful API references for OpenAPI compatible, and customizable built on-top of Vue. Elysia now ship @elysia/swagger package by using Scalar as a default provider, with option to switch back to Swagger UI if need. |
| 18 | + |
| 19 | + - - meta |
| 20 | + - property: 'og:image' |
| 21 | + content: https://elysiajs.com/blog/elysia-08/gate-of-steiner.webp |
| 22 | + |
| 23 | + - - meta |
| 24 | + - property: 'twitter:image' |
| 25 | + content: https://elysiajs.com/blog/elysia-08/gate-of-steiner.webp |
| 26 | +--- |
| 27 | + |
| 28 | +<script setup> |
| 29 | + import Blog from '../../components/blog/Layout.vue' |
| 30 | +</script> |
| 31 | + |
| 32 | +<Blog |
| 33 | + title="Introducing support for Scalar - Elysia" |
| 34 | + src="/blog/elysia-scalar/scalar-by-default.webp" |
| 35 | + alt="Scalar Web client on the left with the word 'Scalar by default' on the right with Elysia logo under the title" |
| 36 | + author="saltyaom" |
| 37 | + date="7 Jan 2024" |
| 38 | +> |
| 39 | +
|
| 40 | +We believe that good developer experience is crucial to create good software. |
| 41 | + |
| 42 | +Giving you, developers. Wonderful tools have been our mission since day one of creating Elysia. |
| 43 | + |
| 44 | +> **We believe in creativity.** |
| 45 | +
|
| 46 | +That developer and open-source community will be able to create a new way to interact with software. |
| 47 | + |
| 48 | +You are the visionary, seeking freedom not bound to words but through actions. |
| 49 | + |
| 50 | +We search for the best tooling we can find and provide, for you to create wonderful things. |
| 51 | + |
| 52 | +Today, we changed the default documentation provider from Swagger to [Scalar](https://github.com/scalar/scalar) by default. |
| 53 | + |
| 54 | +## Scalar |
| 55 | +Starting from 0.8.1 of `@elysiajs/swagger`, the documentation provider will be using Scalar by default. |
| 56 | + |
| 57 | + |
| 58 | + |
| 59 | +Scalar is a modern, beautiful, and customizable OpenAPI specification documentation built on Vue. |
| 60 | + |
| 61 | +Open-source and maintained by a very active team of talented developers. |
| 62 | + |
| 63 | +As same as Swagger UI, providing the same **detail** in route will be available in Scalar documentation to communicate with your team or take note for a route. |
| 64 | + |
| 65 | +```typescript |
| 66 | +import { Elysia } from 'elysia' |
| 67 | + |
| 68 | +new Elysia() |
| 69 | + .get('/', 'hi', { |
| 70 | + detail: { |
| 71 | + title: 'hello', |
| 72 | + description: 'This is a test path' |
| 73 | + } |
| 74 | + }) |
| 75 | +``` |
| 76 | + |
| 77 | +Scalar provides a snippet for working with your favorite tools and programming language to communicate with the endpoint, so even if you or one of your team don't know how to, the documentation will provide that for your need. |
| 78 | + |
| 79 | + |
| 80 | +Scalar also offers search, and expressive UI for composing requests with the basic auto-fill template you need out of the box. |
| 81 | + |
| 82 | + |
| 83 | +Lastly, what you probably are looking for, is dark mode. |
| 84 | + |
| 85 | + |
| 86 | +## Provider |
| 87 | +If not satisfied and prefer to stick with Swagger UI, you can use **provider** option to switch between **swagger-ui** and **scalar**, and it would just work. |
| 88 | + |
| 89 | +```typescript |
| 90 | +import { Elysia } from 'elysia' |
| 91 | +import { swagger } from '@elysiajs/swagger' |
| 92 | + |
| 93 | +new Elysia() |
| 94 | + .use(swagger({ |
| 95 | + provider: 'swagger-ui' |
| 96 | + })) |
| 97 | + .get('/', () => 'hi') |
| 98 | + .post('/hello', () => 'world') |
| 99 | + .listen(8080) |
| 100 | +``` |
| 101 | + |
| 102 | +You can find out more about Scalar customization in [Swagger plugin](/plugins/swagger). |
| 103 | + |
| 104 | +## Wrapping up |
| 105 | + |
| 106 | +That's wrapping it up for today. |
| 107 | + |
| 108 | +Might not be as exciting as the new version or feature, but we plan to add some Elysia-specific integration for Scalar in the future. |
| 109 | + |
| 110 | +Scalar provides a Vue component support that we can build on top of, allowing us to explore and customization with Vue. |
| 111 | + |
| 112 | +If you like to try out Scalar today, update `@elysiajs/swagger` to the latest version and see your new shiny documentation for yourself. |
| 113 | + |
| 114 | +Be sure to check out [Scalar on GitHub](https://github.com/scalar/scalar) as they provide excellent support for many open-source projects out there including Hono, Nestjs, Fastify, and Express as well. |
| 115 | + |
| 116 | +</Blog> |
0 commit comments