Skip to content

Commit 0827565

Browse files
committed
update docs
1 parent 3174fb1 commit 0827565

File tree

541 files changed

+19129
-26253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

541 files changed

+19129
-26253
lines changed

README.md

Lines changed: 9 additions & 140 deletions
Original file line numberDiff line numberDiff line change
@@ -38,12 +38,18 @@ work with static and server target
3838

3939
for nuxt 3 need add vite.config.ts
4040

41+
4142
## Documentation and Support
4243

4344
- **Version Information:** The module is compatible with various Nuxt versions, supporting specific features based on the version.
44-
- **Release Notes:** [View Changes and Updates](https://github.com/on-org/nuxt-openapi-docs-module/blob/main/changelog.md)
45-
- **Demo and Examples:** [See it in Action](https://on-org.github.io/nuxt-openapi-docs-module/)
46-
- **Live Example:** [Lite example on StackBlitz](https://stackblitz.com/edit/github-j7idul?file=README.md)
45+
- **Documentation:** [Browse Full Documentation](https://on-org.github.io/nuxt-openapi-docs-module/)
46+
- **Release Notes:** [Browse Change Log](https://on-org.github.io/nuxt-openapi-docs-module/changelog)
47+
- **Demo and Examples:** [View Live Demo](https://on-org.github.io/nuxt-openapi-docs-module/docs)
48+
- **Live Example:** [Interactive Example on StackBlitz](https://stackblitz.com/edit/github-j7idul?file=README.md)
49+
- **Localization:** [Explore Localization Features](https://on-org.github.io/nuxt-openapi-docs-module/localization)
50+
- **Plugin:** [Learn About Plugins](https://on-org.github.io/nuxt-openapi-docs-module/plugin)
51+
- **Custom Pages:** [Custom Pages Overview](https://on-org.github.io/nuxt-openapi-docs-module/custom_pages)
52+
- **Development and Customization:** [Guide to Development and Customization](https://on-org.github.io/nuxt-openapi-docs-module/development)
4753

4854
## Features
4955

@@ -123,140 +129,3 @@ module.exports = {
123129
- **'locales'**: Define supported locales.
124130
- **'logo'**: Custom logo in SVG format.
125131
- **'footer'**: Custom footer content.
126-
127-
## Usage
128-
129-
### Folder Structure
130-
131-
Place your OpenAPI specification files (e.g., **'api1.yaml'**', **'api2.yaml'**) in the specified **'folder'**.
132-
133-
### Localization
134-
135-
To enable localization, add the **'x-locales'** and locale-specific summaries in your OpenAPI specification files:
136-
137-
```yaml
138-
info:
139-
x-locales:
140-
en: English
141-
ru: Русский
142-
143-
paths:
144-
/pet:
145-
post:
146-
summary: Add a new pet to the store
147-
x-summary-ru: Добавить нового питомца в магазин
148-
```
149-
150-
Example: **'playground2/docs/openapi/localization.yaml'** and **'playground2/nuxt.config.js'**
151-
152-
153-
### Plugin
154-
155-
Here's a description of all the properties and methods of the OpenApiPlugin interface:
156-
157-
- `addParam(pos: 'headers'|'query'|'postData'|'path'|'cookie', name: string, value: string, type?: string): void`
158-
This method allows you to add a parameter to the API documentation. The pos parameter specifies the position of the parameter (headers, query, postData, path, or cookie), while name and value specify the name and value of the parameter, respectively. The type parameter is optional and specifies the data type of the parameter.
159-
- `clearParams(): void`
160-
This method clears all the parameters that have been added to the API documentation.
161-
- `addLocale(lang: string, locale: {[key: string]: string}): void`
162-
This method allows you to add a translation for a specific language. The lang parameter specifies the language code (e.g., "en", "fr", "es"), while the locale parameter is an object that maps translation keys to their respective translations.
163-
- `setAccess(accessor: (path: string) => boolean): boolean`
164-
This method sets the accessor function that determines whether the user has access to a specific file. The accessor function takes a file path as input and returns a boolean indicating whether the user has access.
165-
- `setRouteInfo(routeInfo: (file: string, url: string, method: string) => string|null): void;`
166-
add route info to path
167-
168-
Example: example/plugins/auth.js
169-
170-
```js
171-
context.$openapidoc.setAccess((file) => {
172-
return file !== 'no-access';
173-
})
174-
175-
context.$openapidoc.setFooter('<div><b>Nuxt OpenApi doc panel</b> </div>')
176-
```
177-
178-
### Development and Customization
179-
180-
For developers looking to contribute or customize the module:
181-
182-
```bash
183-
# Install dependencies
184-
npm install
185-
186-
# Generate type stubs and start development
187-
npm run dev:prepare
188-
npm run dev
189-
190-
# Build the playground for production
191-
npm run dev:build
192-
```
193-
194-
195-
### Custom pages
196-
197-
1. Create custom page, for example `pages/docs/petstore_extended/:locale/custom/page1.vue`
198-
199-
- **'docs'** - path from config (docs default)
200-
- **'petstore_extended'** - doc name
201-
- **':locale'** - locale (en default)
202-
- **'custom'** - static path
203-
- **'page1'** - page name
204-
205-
2. create vue component, for example `page1.vue`
206-
207-
```js
208-
<template>
209-
<div class="items-top min-h-screen bg-gray-100 sm:items-center sm:pt-0">
210-
<client-only>
211-
<div v-html="content"></div>
212-
</client-only>
213-
<hr>
214-
<div>my custom page</div>
215-
</div>
216-
</template>
217-
218-
<script setup lang="ts">
219-
defineI18nRoute({
220-
locales: ['en', 'ru'],
221-
});
222-
223-
definePageMeta({
224-
layout: 'open-api-layout-petstore_extended',
225-
});
226-
</script>
227-
228-
```
229-
230-
where open-api-layout-petstore_extended is `open-api-layout-${doc_name}`
231-
232-
here you need to replace the page parameter to you page name
233-
234-
3. add custom routes to openapi specification
235-
236-
```js
237-
x-custom-path:
238-
title: 'Custom'
239-
description: 'Custom pages'
240-
paths:
241-
page1:
242-
title: 'Custom page 1'
243-
description: 'Custom pages 1'
244-
```
245-
246-
page1 - your file name
247-
248-
Example `playground2/docs/openapi/page.yaml`
249-
250-
### Plugin Interface
251-
252-
The module provides a plugin interface to add parameters, clear them, handle localization, and set access controls dynamically:
253-
254-
```javascript
255-
// Example of setting access control
256-
context.$openapidoc.setAccess((file) => {
257-
return file !== 'no-access';
258-
});
259-
260-
// Example of setting a custom footer
261-
context.$openapidoc.setFooter('<div><b>Nuxt OpenApi doc panel</b> </div>')
262-
```

0 commit comments

Comments
 (0)