Skip to content

Commit

Permalink
Add missing exports (#109)
Browse files Browse the repository at this point in the history
Co-authored-by: Igor Savin <igor.savin@lokalise.com>
  • Loading branch information
kibertoad and Igor Savin authored Sep 24, 2024
1 parent 0aa6156 commit 76ef73a
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 10 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ run();
```

## How to create refs to the schemas?

It is possible to create refs to the schemas by using the `createJsonSchemaTransformObject` function. You provide the schemas as an object and fastifySwagger will create a OpenAPI document in which the schemas are referenced. The following example creates a ref to the `User` schema and will include the `User` schema in the OpenAPI document.

```ts
Expand Down
15 changes: 15 additions & 0 deletions index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
export {
type ZodTypeProvider,
type FastifyPluginAsyncZod,
type FastifyPluginCallbackZod,
jsonSchemaTransform,
createJsonSchemaTransform,
createJsonSchemaTransformObject,
serializerCompiler,
validatorCompiler,
} from './src/core';

export {
ResponseValidationError,
type ResponseValidationErrorDetails,
} from './src/ResponseValidationError';
File renamed without changes.
4 changes: 2 additions & 2 deletions test/fastify-swagger.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ import Fastify from 'fastify';
import * as validator from 'oas-validator';
import { z } from 'zod';

import type { ZodTypeProvider } from '../src';
import type { ZodTypeProvider } from '../src/core';
import {
createJsonSchemaTransformObject,
jsonSchemaTransform,
serializerCompiler,
validatorCompiler,
} from '../src';
} from '../src/core';

describe('transformer', () => {
it('generates types for fastify-swagger correctly', async () => {
Expand Down
4 changes: 2 additions & 2 deletions test/request-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import type { FastifyInstance } from 'fastify';
import Fastify from 'fastify';
import { z } from 'zod';

import type { ZodTypeProvider } from '../src';
import { serializerCompiler, validatorCompiler } from '../src';
import type { ZodTypeProvider } from '../src/core';
import { serializerCompiler, validatorCompiler } from '../src/core';

describe('response schema', () => {
let app: FastifyInstance;
Expand Down
4 changes: 2 additions & 2 deletions test/response-schema.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import type { FastifyInstance } from 'fastify';
import Fastify from 'fastify';
import { z } from 'zod';

import type { ZodTypeProvider } from '../src';
import { serializerCompiler, validatorCompiler } from '../src';
import type { ResponseValidationError } from '../src/ResponseValidationError';
import type { ZodTypeProvider } from '../src/core';
import { serializerCompiler, validatorCompiler } from '../src/core';

describe('response schema', () => {
describe('does not fail on empty response schema (204)', () => {
Expand Down
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"compilerOptions": {
"declaration": true,
"rootDir": "src",
"outDir": "dist",
"esModuleInterop": true,
"skipLibCheck": true,
Expand Down
4 changes: 2 additions & 2 deletions types/index.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import Fastify from 'fastify';
import { expectAssignable, expectType } from 'tsd';
import { z } from 'zod';

import { serializerCompiler, validatorCompiler } from '../src/index';
import type { ZodTypeProvider } from '../src/index';
import { serializerCompiler, validatorCompiler } from '../src/core';
import type { ZodTypeProvider } from '../src/core';

const fastify = Fastify().withTypeProvider<ZodTypeProvider>();

Expand Down
2 changes: 1 addition & 1 deletion types/plugin.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import fp from 'fastify-plugin';
import { expectType } from 'tsd';
import { z } from 'zod';

import type { FastifyPluginAsyncZod, FastifyPluginCallbackZod } from '../src/index';
import type { FastifyPluginAsyncZod, FastifyPluginCallbackZod } from '../src/core';

// Ensure the defaults of FastifyPluginAsyncZod are the same as FastifyPluginAsync
export const pluginAsyncDefaults: FastifyPluginAsync = async (fastify, options) => {
Expand Down

0 comments on commit 76ef73a

Please sign in to comment.