mirror of
https://github.com/ferdikoomen/openapi-typescript-codegen.git
synced 2025-12-08 20:16:21 +00:00
- Working new validation
This commit is contained in:
parent
d50724ba97
commit
266a0dadba
@ -1,4 +1,9 @@
|
||||
export type {{{name}}} = Array<{{>type}}>{{#if nullable}} | null{{/if}};
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
export type {{{name}}} = {{>type}}{{#if nullable}} | null{{/if}};
|
||||
|
||||
export namespace {{{name}}} {
|
||||
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
export type {{{name}}} = {{>type}}{{#if nullable}} | null{{/if}};
|
||||
|
||||
export namespace {{{name}}} {
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
export enum {{{name}}} {
|
||||
{{#each enum}}
|
||||
{{{name}}} = {{{value}}},
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
export type {{{name}}} = {{>type}}{{#if nullable}} | null{{/if}};
|
||||
|
||||
export namespace {{{name}}} {
|
||||
|
||||
@ -1,3 +1,8 @@
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
export interface {{{name}}}{{{template}}}{{#if extends}} extends{{#each extends}} {{{this}}}{{/each}}{{/if}} {
|
||||
{{#each properties}}
|
||||
{{#if description}}
|
||||
|
||||
@ -8,25 +8,19 @@
|
||||
import { {{{this}}} } from '../models/{{{this}}}';
|
||||
{{/each}}
|
||||
{{/if}}
|
||||
import Dictionary from '../core/Dictionary';
|
||||
import { Dictionary } from '../core/Dictionary';
|
||||
import * as yup from 'yup';
|
||||
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
|
||||
{{~#eq export 'reference'~}}
|
||||
{{#eq export 'reference'}}
|
||||
{{>exportReference}}
|
||||
{{~else eq export 'generic'~}}
|
||||
{{else eq export 'generic'}}
|
||||
{{>exportGeneric}}
|
||||
{{~else eq export 'enum'~}}
|
||||
{{else eq export 'enum'}}
|
||||
{{>exportEnum}}
|
||||
{{~else eq export 'array'~}}
|
||||
{{else eq export 'array'}}
|
||||
{{>exportArray}}
|
||||
{{~else eq export 'dictionary'~}}
|
||||
{{else eq export 'dictionary'}}
|
||||
{{>exportDictionary}}
|
||||
{{~else eq export 'interface'~}}
|
||||
{{else eq export 'interface'}}
|
||||
{{>exportInterface}}
|
||||
{{~/eq~}}
|
||||
{{/eq}}
|
||||
|
||||
@ -1,12 +1,5 @@
|
||||
{{~#if properties~}}
|
||||
{
|
||||
{{#each properties}}
|
||||
{{#if readOnly}}readonly {{/if}}{{{name}}}{{#unless required}}?{{/unless}}: {{>type}}{{#if nullable}} | null{{/if}},
|
||||
{{/each}}
|
||||
}
|
||||
{{~else if link~}}
|
||||
{{{base}}}<{{>type link}}>
|
||||
{{~#if link~}}
|
||||
Array<{{>type link}}>
|
||||
{{~else~}}
|
||||
{{{type}}}
|
||||
Array<{{{type}}}>
|
||||
{{~/if~}}
|
||||
// TODO: Per type ook een nette export maken!
|
||||
|
||||
@ -1,12 +1,5 @@
|
||||
{{~#if properties~}}
|
||||
{
|
||||
{{#each properties}}
|
||||
{{#if readOnly}}readonly {{/if}}{{{name}}}{{#unless required}}?{{/unless}}: {{>type}}{{#if nullable}} | null{{/if}},
|
||||
{{/each}}
|
||||
}
|
||||
{{~else if link~}}
|
||||
{{{base}}}<{{>type link}}>
|
||||
{{~#if link~}}
|
||||
Dictionary<{{>type link}}>
|
||||
{{~else~}}
|
||||
{{{type}}}
|
||||
Dictionary<{{{type}}}>
|
||||
{{~/if~}}
|
||||
// TODO: Per type ook een nette export maken!
|
||||
|
||||
@ -1,12 +1 @@
|
||||
{{~#if properties~}}
|
||||
{
|
||||
{{#each properties}}
|
||||
{{#if readOnly}}readonly {{/if}}{{{name}}}{{#unless required}}?{{/unless}}: {{>type}}{{#if nullable}} | null{{/if}},
|
||||
{{/each}}
|
||||
}
|
||||
{{~else if link~}}
|
||||
{{{base}}}<{{>type link}}>
|
||||
{{~else~}}
|
||||
{{{type}}}
|
||||
{{~/if~}}
|
||||
// TODO: Per type ook een nette export maken!
|
||||
any
|
||||
|
||||
@ -1,12 +1 @@
|
||||
{{~#if properties~}}
|
||||
{
|
||||
{{#each properties}}
|
||||
{{#if readOnly}}readonly {{/if}}{{{name}}}{{#unless required}}?{{/unless}}: {{>type}}{{#if nullable}} | null{{/if}},
|
||||
{{/each}}
|
||||
}
|
||||
{{~else if link~}}
|
||||
{{{base}}}<{{>type link}}>
|
||||
{{~else~}}
|
||||
{{{type}}}
|
||||
{{~/if~}}
|
||||
// TODO: Per type ook een nette export maken!
|
||||
{{{base}}}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
{{~#if properties~}}
|
||||
{
|
||||
{{#each properties}}
|
||||
{{#if readOnly}}readonly {{/if}}{{{name}}}{{#unless required}}?{{/unless}}: {{>type}}{{#if nullable}} | null{{/if}},
|
||||
{{/each}}
|
||||
{{#each properties}}
|
||||
{{#each properties}}
|
||||
{{#if description}}
|
||||
/**
|
||||
* {{{description}}}
|
||||
*/
|
||||
{{/if}}
|
||||
{{#if readOnly}}readonly {{/if}}{{{name}}}{{#unless required}}?{{/unless}}: {{>type}}{{#if nullable}} | null{{/if}},
|
||||
{{/each}}
|
||||
{{/each}}
|
||||
}
|
||||
{{~else if link~}}
|
||||
{{{base}}}<{{>type link}}>
|
||||
{{~else~}}
|
||||
{{{type}}}
|
||||
{{~/if~}}
|
||||
// TODO: Per type ook een nette export maken!
|
||||
|
||||
@ -1,12 +1 @@
|
||||
{{~#if properties~}}
|
||||
{
|
||||
{{#each properties}}
|
||||
{{#if readOnly}}readonly {{/if}}{{{name}}}{{#unless required}}?{{/unless}}: {{>type}}{{#if nullable}} | null{{/if}},
|
||||
{{/each}}
|
||||
}
|
||||
{{~else if link~}}
|
||||
{{{base}}}<{{>type link}}>
|
||||
{{~else~}}
|
||||
{{{type}}}
|
||||
{{~/if~}}
|
||||
// TODO: Per type ook een nette export maken!
|
||||
{{{base}}}
|
||||
|
||||
@ -1 +1,5 @@
|
||||
yup.mixed()
|
||||
{{~#if link~}}
|
||||
yup.array<{{>type link}}>().of({{>validation link}})
|
||||
{{~else~}}
|
||||
yup.array<{{{type}}}>().of({{{base}}}.schema)
|
||||
{{~/if~}}
|
||||
|
||||
@ -1 +1,19 @@
|
||||
yup.mixed()
|
||||
{{~#if link~}}
|
||||
yup.lazy<Dictionary<{{>type link}}>>(value =>
|
||||
yup.object<Dictionary<{{>type link}}>>().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: {{>validation link}},
|
||||
}), {})
|
||||
)
|
||||
)
|
||||
{{~else~}}
|
||||
yup.lazy<Dictionary<{{{type}}}>>(value =>
|
||||
yup.object<Dictionary<{{{type}}}>>().shape(
|
||||
Object.entries(value).reduce((obj, item) => ({
|
||||
...obj,
|
||||
[item[0]]: {{{base}}}.schema,
|
||||
}), {})
|
||||
)
|
||||
)
|
||||
{{~/if~}}
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
{{~/if~}}
|
||||
yup.object{{#if name}}<{{{name}}}>{{/if}}().shape({
|
||||
{{#each properties}}
|
||||
{{{name}}}: yup.lazy(() => {{>validation this}}.default(undefined)){{#if required}}.required(){{/if}}{{#if nullable}}.nullable(){{/if}},
|
||||
{{{name}}}: yup.lazy(() => {{>validation}}.default(undefined)){{#if required}}.required(){{/if}}{{#if nullable}}.nullable(){{/if}},
|
||||
{{/each}}
|
||||
}).noUnknown()
|
||||
{{~#if extends~}}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user