Replies: 2 comments 4 replies
-
Run Spec is available at http://localhost:3000/_nitro/openapi.json |
Beta Was this translation helpful? Give feedback.
4 replies
-
QuestionIs it possible to configure Nitro OpenAPI to use a generator from Example Codeimport { extendZodWithOpenApi, OpenApiGeneratorV3 } from '@asteasolutions/zod-to-openapi';
import { z } from 'zod';
extendZodWithOpenApi(z);
const fieldDefinitions = {
'title': {
label: 'Project name',
placeholder: 'Project name',
validation: z
.string()
.min(1, "Project name is required")
.openapi({ description: 'Project name' }),
},
'case-number': {
label: 'Case-number',
placeholder: 'Case-number',
validation: z
.string()
.min(1, "Case-number is required")
.openapi({ description: 'Case-number' }),
},
'case-manager': {
label: 'Case-manager',
placeholder: 'Case-manager',
validation: z
.string()
.min(1, "Case-manager is required")
.openapi({ description: 'Case-manager' }),
},
'contributor': {
label: 'Contributor',
placeholder: 'Contributor',
validation: z
.string()
.min(1, "Contributor is required")
.openapi({ description: 'Project contributor' }),
},
};
export const metadataSchema = z
.object(
Object.fromEntries(
Object.entries(fieldDefinitions).map(([key, { validation }]) => [
key,
validation,
])
)
)
.openapi('Metadata');
export const formFields = Object.entries(fieldDefinitions).map(
([key, { label, placeholder }]) => ({
id: key,
label,
type: 'text',
placeholder,
})
);
const generator = new OpenApiGeneratorV3([metadataSchema]); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
How to use it? I specified the experimental in a config, but what is a next step to generate Open Api Specs?
Br,
Alex
Beta Was this translation helpful? Give feedback.
All reactions