Class: Apiwork::Export::Zod

Inherits:
Base
  • Object
show all
Defined in:
lib/apiwork/export/zod.rb

Instance Attribute Summary

Attributes inherited from Base

#api, #api_base_path, #options

Instance Method Summary collapse

Methods inherited from Base

content_type_for, export_name, extract_nested_option, extract_nested_option_from_env, extract_options, #extract_options_from_config, extract_options_from_env, file_extension, file_extension_for, generate, hash_output?, #initialize, #key_format, output, #serialize, string_output?, supports_format?, #transform_key, #validate_options!

Methods included from Configurable

define, option

Constructor Details

This class inherits a constructor from Apiwork::Export::Base

Instance Method Details

#generateObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/apiwork/export/zod.rb', line 12

def generate
  parts = []

  parts << "import { z } from 'zod';\n"

  zod_schemas = ZodMapper.map(self, surface)
  if zod_schemas.present?
    parts << zod_schemas
    parts << ''
  end

  typescript_types = TypeScriptMapper.map(self, surface)
  if typescript_types.present?
    parts << typescript_types
    parts << ''
  end

  parts.join("\n")
end