Skip to content

Commit 9eec7b9

Browse files
committed
emit types instead of classes
1 parent 1ccfeea commit 9eec7b9

File tree

2 files changed

+206
-532
lines changed

2 files changed

+206
-532
lines changed

codegen/templates/typescript.ts.erb

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1-
import { Type } from 'class-transformer'
2-
import 'reflect-metadata'
3-
41
<% @schemas.each do |key, schema| -%>
5-
export class <%= class_name(key) -%> {
2+
export type <%= class_name(key) -%> = {
63
<%- schema['properties'].each do |property_name, property| -%>
7-
8-
<%- ref = property['$ref'] || property['items'] && property['items']['$ref'] -%>
9-
<%- if ref -%>
10-
<%- %> @Type(() => <%= class_name(ref) -%>)
11-
<%- end -%>
124
<%- if (schema['required'] || []).index(property_name) -%>
13-
<%- %> <%= property_name %>: <%= type_for(class_name(key), property_name, property) -%> = <%= default_value(class_name(key), property_name, property) -%>
5+
<%- %> <%= property_name %>: <%= type_for(class_name(key), property_name, property) -%>
146
<%- else -%>
157
<%- %> <%= property_name %>?: <%= type_for(class_name(key), property_name, property) -%>
168
<%- end -%>

0 commit comments

Comments
 (0)