Skip to content

Commit

Permalink
feat: add Nuxt client
Browse files Browse the repository at this point in the history
  • Loading branch information
mrlubos committed Dec 31, 2024
1 parent a7aa2fe commit d3fccb0
Show file tree
Hide file tree
Showing 42 changed files with 6,760 additions and 300 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ yarn-error.log*
dist
coverage
.env
.nuxt
.svelte-kit

# test files
Expand Down
1 change: 1 addition & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
**/node_modules
**/templates
**/dist
**/.nuxt
**/.svelte-kit
**/.vitepress/cache
**/.vitepress/dist
Expand Down
2 changes: 1 addition & 1 deletion docs/openapi-ts/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ Alternatively, you can use `openapi-ts.config.js` and configure the export state
Input is the first thing you must define. It can be a path, URL, or a string content resolving to an OpenAPI specification. Hey API supports all valid OpenAPI versions and file formats.

::: info
We use [`@hey-api/json-schema-ref-parser`](https://github.com/hey-api/json-schema-ref-parser) to resolve file locations. Please note that accessing a HTTPS URL on localhost has a known [workaround](https://github.com/hey-api/openapi-ts/issues/276).
If you use an HTTPS URL with a self-signed certificate in development, you will need to set [`NODE_TLS_REJECT_UNAUTHORIZED=0`](https://github.com/hey-api/openapi-ts/issues/276#issuecomment-2043143501) in your environment.
:::

## Output
Expand Down
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export default tseslint.config(
'**/test/e2e/generated/',
'**/test/generated/',
'**/__snapshots__/',
'**/.nuxt/',
'**/.svelte-kit/',
'**/.vitepress/cache',
'**/.vitepress/dist',
Expand Down
24 changes: 24 additions & 0 deletions examples/openapi-ts-nuxt/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Nuxt dev/build outputs
.output
.data
.nuxt
.nitro
.cache
dist

# Node dependencies
node_modules

# Logs
logs
*.log

# Misc
.DS_Store
.fleet
.idea

# Local env files
.env
.env.*
!.env.example
75 changes: 75 additions & 0 deletions examples/openapi-ts-nuxt/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Nuxt Minimal Starter

Look at the [Nuxt documentation](https://nuxt.com/docs/getting-started/introduction) to learn more.

## Setup

Make sure to install dependencies:

```bash
# npm
npm install

# pnpm
pnpm install

# yarn
yarn install

# bun
bun install
```

## Development Server

Start the development server on `http://localhost:3000`:

```bash
# npm
npm run dev

# pnpm
pnpm dev

# yarn
yarn dev

# bun
bun run dev
```

## Production

Build the application for production:

```bash
# npm
npm run build

# pnpm
pnpm build

# yarn
yarn build

# bun
bun run build
```

Locally preview production build:

```bash
# npm
npm run preview

# pnpm
pnpm preview

# yarn
yarn preview

# bun
bun run preview
```

Check out the [deployment documentation](https://nuxt.com/docs/getting-started/deployment) for more information.
7 changes: 7 additions & 0 deletions examples/openapi-ts-nuxt/app.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<div>
<NuxtRouteAnnouncer />
<!-- <NuxtWelcome /> -->
<Home />
</div>
</template>
3 changes: 3 additions & 0 deletions examples/openapi-ts-nuxt/client/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// This file is auto-generated by @hey-api/openapi-ts
export * from './sdk.gen';
export * from './types.gen';
244 changes: 244 additions & 0 deletions examples/openapi-ts-nuxt/client/schemas.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,244 @@
// This file is auto-generated by @hey-api/openapi-ts

export const OrderSchema = {
properties: {
complete: {
type: 'boolean',
},
id: {
example: 10,
format: 'int64',
type: 'integer',
},
petId: {
example: 198772,
format: 'int64',
type: 'integer',
},
quantity: {
example: 7,
format: 'int32',
type: 'integer',
},
shipDate: {
format: 'date-time',
type: 'string',
},
status: {
description: 'Order Status',
enum: ['placed', 'approved', 'delivered'],
example: 'approved',
type: 'string',
},
},
type: 'object',
'x-swagger-router-model': 'io.swagger.petstore.model.Order',
xml: {
name: 'order',
},
} as const;

export const CustomerSchema = {
properties: {
address: {
items: {
$ref: '#/components/schemas/Address',
},
type: 'array',
xml: {
name: 'addresses',
wrapped: true,
},
},
id: {
example: 100000,
format: 'int64',
type: 'integer',
},
username: {
example: 'fehguy',
type: 'string',
},
},
type: 'object',
xml: {
name: 'customer',
},
} as const;

export const AddressSchema = {
properties: {
city: {
example: 'Palo Alto',
type: 'string',
},
state: {
example: 'CA',
type: 'string',
},
street: {
example: '437 Lytton',
type: 'string',
},
zip: {
example: 94301,
type: 'string',
},
},
type: 'object',
xml: {
name: 'address',
},
} as const;

export const CategorySchema = {
properties: {
id: {
example: 1,
format: 'int64',
type: 'integer',
},
name: {
example: 'Dogs',
type: 'string',
},
},
type: 'object',
'x-swagger-router-model': 'io.swagger.petstore.model.Category',
xml: {
name: 'category',
},
} as const;

export const UserSchema = {
properties: {
email: {
example: '[email protected]',
type: 'string',
},
firstName: {
example: 'John',
type: 'string',
},
id: {
example: 10,
format: 'int64',
type: 'integer',
},
lastName: {
example: 'James',
type: 'string',
},
password: {
example: 12345,
type: 'string',
},
phone: {
example: 12345,
type: 'string',
},
userStatus: {
description: 'User Status',
example: 1,
format: 'int32',
type: 'integer',
},
username: {
example: 'theUser',
type: 'string',
},
},
type: 'object',
'x-swagger-router-model': 'io.swagger.petstore.model.User',
xml: {
name: 'user',
},
} as const;

export const TagSchema = {
properties: {
id: {
format: 'int64',
type: 'integer',
},
name: {
type: 'string',
},
},
type: 'object',
'x-swagger-router-model': 'io.swagger.petstore.model.Tag',
xml: {
name: 'tag',
},
} as const;

export const PetSchema = {
properties: {
category: {
$ref: '#/components/schemas/Category',
},
id: {
example: 10,
format: 'int64',
type: 'integer',
},
name: {
example: 'doggie',
type: 'string',
},
photoUrls: {
items: {
type: 'string',
xml: {
name: 'photoUrl',
},
},
type: 'array',
xml: {
wrapped: true,
},
},
status: {
description: 'pet status in the store',
enum: ['available', 'pending', 'sold'],
type: 'string',
},
tags: {
items: {
$ref: '#/components/schemas/Tag',
xml: {
name: 'tag',
},
},
type: 'array',
xml: {
wrapped: true,
},
},
},
required: ['name', 'photoUrls'],
type: 'object',
'x-swagger-router-model': 'io.swagger.petstore.model.Pet',
xml: {
name: 'pet',
},
} as const;

export const ApiResponseSchema = {
properties: {
code: {
format: 'int32',
type: 'integer',
},
message: {
type: 'string',
},
type: {
type: 'string',
},
},
type: 'object',
xml: {
name: '##default',
},
} as const;
Loading

0 comments on commit d3fccb0

Please sign in to comment.