tla-sbuilder 0.2.2 → 0.3.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (127) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +150 -116
  3. data/VERSION +1 -1
  4. data/lib/cli/cli-customer.rb +23 -3
  5. data/lib/cli/cli-pet.rb +66 -12
  6. data/lib/cli/cli-text.rb +127 -8
  7. data/lib/cli/cli.rb +49 -6
  8. data/lib/sbuilder.rb +26 -3
  9. data/lib/sbuilder/constants.rb +165 -6
  10. data/lib/sbuilder/controller.rb +943 -169
  11. data/lib/sbuilder/controller_utils.rb +122 -0
  12. data/lib/sbuilder/default-sbuilder.yaml +38 -44
  13. data/lib/sbuilder/domain.rb +160 -36
  14. data/lib/sbuilder/domain_cardinality.rb +1 -1
  15. data/lib/sbuilder/domain_range.rb +102 -0
  16. data/lib/sbuilder/domain_type.rb +150 -0
  17. data/lib/sbuilder/domain_value.rb +21 -13
  18. data/lib/sbuilder/exception.rb +16 -0
  19. data/lib/sbuilder/extension_loader.rb +67 -686
  20. data/lib/sbuilder/extension_loader_deprecated_step_extensions.rb +711 -0
  21. data/lib/sbuilder/extension_loader_step_generator.rb +876 -0
  22. data/lib/sbuilder/facade/{api_loader.rb → api_loader_facade.rb} +176 -45
  23. data/lib/sbuilder/facade/api_loader_plugin.rb +6 -32
  24. data/lib/sbuilder/facade/api_loader_plugin_mixer.rb +35 -0
  25. data/lib/sbuilder/facade/facade_constants.rb +23 -0
  26. data/lib/sbuilder/facade/loader_plugin_root.rb +56 -0
  27. data/lib/sbuilder/facade/param_set_root.rb +55 -0
  28. data/lib/sbuilder/facade/snippet_loader_facade.rb +600 -0
  29. data/lib/sbuilder/facade/snippet_loader_plugin.rb +76 -0
  30. data/lib/sbuilder/facade/snippet_loader_plugin_mixer.rb +56 -0
  31. data/lib/sbuilder/factory.rb +224 -45
  32. data/lib/sbuilder/model.rb +125 -45
  33. data/lib/sbuilder/mustache/template.rb +107 -58
  34. data/lib/sbuilder/mustache/template_reader.rb +56 -46
  35. data/lib/sbuilder/mustache/template_reader_context.rb +64 -234
  36. data/lib/sbuilder/mustache/template_resolve.rb +103 -0
  37. data/lib/sbuilder/mustache/template_root.rb +71 -0
  38. data/lib/sbuilder/param_set.rb +30 -15
  39. data/lib/sbuilder/param_set_db.rb +1 -1
  40. data/lib/sbuilder/param_set_def.rb +6 -1
  41. data/lib/sbuilder/param_set_def_func.rb +39 -0
  42. data/lib/sbuilder/param_set_if.rb +45 -10
  43. data/lib/sbuilder/param_set_loader_swagger.rb +56 -26
  44. data/lib/sbuilder/param_set_step.rb +1 -1
  45. data/lib/sbuilder/param_sets.rb +2 -1
  46. data/lib/sbuilder/parameter.rb +9 -3
  47. data/lib/sbuilder/parameter_container.rb +1 -1
  48. data/lib/sbuilder/parameter_dom.rb +17 -5
  49. data/lib/sbuilder/parameter_ref.rb +39 -10
  50. data/lib/sbuilder/parser/parser_facade.rb +310 -0
  51. data/lib/sbuilder/resolver.rb +11 -6
  52. data/lib/sbuilder/resolver_loader.rb +1 -1
  53. data/lib/sbuilder/resolver_loader_yaml.rb +1 -1
  54. data/lib/sbuilder/resolver_rule.rb +1 -1
  55. data/lib/sbuilder/resolver_rule_match.rb +10 -4
  56. data/lib/sbuilder/resolver_rule_ref.rb +1 -1
  57. data/lib/sbuilder/setup_loader.rb +49 -0
  58. data/lib/sbuilder/setup_loader_env.rb +478 -0
  59. data/lib/sbuilder/setup_loader_pref.rb +56 -0
  60. data/lib/sbuilder/snippet_loader_simple.rb +125 -0
  61. data/lib/sbuilder/spec/api_loader.rb +34 -0
  62. data/lib/sbuilder/spec/api_loader_facade.rb +169 -32
  63. data/lib/sbuilder/spec/loader_plugin.rb +98 -0
  64. data/lib/sbuilder/spec/snippet_loader.rb +228 -0
  65. data/lib/sbuilder/symbol_table.rb +279 -0
  66. data/lib/utils/{cache_lines.rb → fileio.rb} +8 -1
  67. data/lib/utils/logger.rb +2 -1
  68. data/lib/utils/powerset.rb +13 -0
  69. data/lib/utils/validate.rb +38 -0
  70. data/mustache/cfg/const_def.mustache +2 -0
  71. data/mustache/cfg/macro_run.mustache +1 -4
  72. data/mustache/data-model-header.mustache +1 -0
  73. data/mustache/definition_types.mustache +34 -4
  74. data/mustache/domains.mustache +1 -1
  75. data/mustache/domains_assign.mustache +1 -1
  76. data/mustache/infrastructure-service-init.mustache +1 -1
  77. data/mustache/interface_processes.mustache +16 -10
  78. data/mustache/interface_types.mustache +37 -11
  79. data/mustache/operator-infrastructure-service.mustache +1 -1
  80. data/mustache/resources/schedule_operator_new_step.tla +8 -0
  81. data/mustache/resources/schedule_process_macro.tla +37 -0
  82. data/mustache/resources/schedule_process_procedure.tla +22 -0
  83. data/mustache/resources/schedule_throw.tla +16 -0
  84. data/mustache/setup/domains_run.mustache +8 -2
  85. data/mustache/setup/operator_run.mustache +0 -4
  86. data/mustache/setup/steps_run.mustache +4 -3
  87. data/mustache/setup/steps_run_parameterBind.mustache +14 -6
  88. data/mustache/setup/steps_run_parameterExact.mustache +7 -3
  89. data/mustache/state_type_invariant-infrastructure-service.mustache +9 -4
  90. data/mustache/tla/const_def.mustache +1 -1
  91. data/mustache/tla/macro_run.mustache +7 -1
  92. data/mustache/tla/module_header.mustache +1 -1
  93. data/mustache/tla/operator_run.mustache +8 -5
  94. data/mustache/tla/plc_define_run.mustache +45 -36
  95. data/mustache/tla/plc_run_state.mustache +12 -5
  96. data/src-extend/extend/extend_assumptions.mustache +3 -0
  97. data/src-extend/extend/extend_const.mustache +3 -0
  98. data/src-extend/extend/extend_implementation.mustache +3 -0
  99. data/src-extend/extend/extend_invariant.mustache +3 -0
  100. data/src-extend/extend/extend_macros.mustache +3 -0
  101. data/src-extend/extend/extend_operations.mustache +3 -0
  102. data/src-extend/extend/extend_state.mustache +3 -0
  103. data/src/pet/extend/extend_assumptions.mustache +4 -0
  104. data/src/pet/extend/extend_implementation.mustache +3 -0
  105. data/src/pet/extend/extend_invariant.mustache +3 -0
  106. data/src/pet/extend/extend_macros.mustache +3 -0
  107. data/src/pet/extend/extend_operations.mustache +4 -0
  108. data/src/pet/extend/extend_state.mustache +3 -0
  109. data/src/pet/interface +5 -5
  110. data/src/pet/interface_delete_pet.tla +1 -1
  111. data/src/pet/interface_get_pet.tla +1 -1
  112. data/src/pet/interface_post_pet.tla +4 -2
  113. data/src/pet/interface_post_tag.tla +1 -1
  114. data/src/pet/interface_put_tag.tla +1 -1
  115. data/tla-sbuilder.gemspec +3 -3
  116. metadata +44 -19
  117. data/mustache/name_definition_type.mustache +0 -5
  118. data/mustache/name_domain.mustache +0 -5
  119. data/mustache/name_domain_value.mustache +0 -5
  120. data/mustache/name_domain_value_prefix.mustache +0 -5
  121. data/mustache/name_interface_response_type.mustache +0 -6
  122. data/mustache/name_interface_type.mustache +0 -6
  123. data/mustache/name_parameter_type.mustache +0 -6
  124. data/mustache/name_process.mustache +0 -6
  125. data/mustache/state_type_invariant.mustache +0 -17
  126. data/mustache/state_variables.mustache +0 -20
  127. data/src-extend/extend/extend_invariant_cfg.mustache +0 -7
@@ -0,0 +1,103 @@
1
+ module Sbuilder
2
+
3
+
4
+ # Find names of templates included from mustache extension point
5
+ # template file.
6
+ #
7
+ # @since 0.3.1
8
+ #
9
+ class TemplateResolve < TemplateRoot
10
+
11
+ include Sbuilder::Utils::MyLogger # mix logger
12
+ PROGNAME = nil
13
+
14
+
15
+ extend Forwardable # for easy delegation
16
+ def_delegators :reader,:get_template
17
+
18
+ # ------------------------------------------------------------------
19
+ # @!group Construtor + configure
20
+
21
+ def initialize( reader, options={} )
22
+ super( reader, options )
23
+
24
+ @logger = getLogger( PROGNAME, options )
25
+ @logger.info( "#{__method__} created" )
26
+
27
+ end
28
+
29
+ # @!endgroup
30
+
31
+ # ------------------------------------------------------------------
32
+ # @!group Public services
33
+
34
+ # Resolve file names used in 'extesion_point'
35
+ #
36
+ # Implementation assumes that this method is called only for
37
+ # extension points.
38
+ #
39
+ # @param extension_point [String] template for extension point
40
+ #
41
+ # @return [String:Array] array filenames for partials called for the 'extension_point'
42
+ def resolve_partials( extension_point )
43
+ @logger.info( "#{__method__} extension_point=#{extension_point}" )
44
+ template = get_template( extension_point )
45
+ @logger.debug( "#{__method__} #{extension_point} -> template #{template}" )
46
+
47
+ # data passed to rendering, in this use empty data, because we
48
+ # are interested only in names included templates
49
+ data = {}
50
+
51
+ # render collects partials used for 'template'
52
+ partialsInit
53
+
54
+ str = render( template, {} )
55
+
56
+ return partialsCalled
57
+
58
+ end
59
+
60
+ # @!endgroup
61
+
62
+ # ------------------------------------------------------------------
63
+ # @!group Called from 'partial' -method
64
+
65
+ # Intercept chain to read template file.
66
+ #
67
+ # Delegates actual read operation to 'get_template' in parent
68
+ # class reader.
69
+ #
70
+ # @param name [:symbol] name of partial template to include
71
+ def get_partial( name )
72
+ @logger.info( "#{__method__} read partial_file=#{name}:#{name.class}" )
73
+
74
+ # this partial called
75
+ partialsAdd( name.to_s )
76
+
77
+ partial = get_template( name )
78
+ return partial
79
+
80
+ end
81
+
82
+ # @!endgroup
83
+
84
+ # ------------------------------------------------------------------
85
+ # @!group Collect partials called
86
+
87
+ def partialsInit()
88
+ @partials=[]
89
+ end
90
+
91
+ def partialsAdd( name )
92
+ @partials << name
93
+ end
94
+
95
+ def partialsCalled
96
+ @partials
97
+ end
98
+
99
+ # @!endgroup
100
+
101
+ end
102
+
103
+ end
@@ -0,0 +1,71 @@
1
+ # coding: utf-8
2
+ require 'mustache' # extendending implementation of
3
+
4
+ module Sbuilder
5
+
6
+ # Abstract base class, implmenting common template methods.
7
+ #
8
+ # @abstract
9
+ class TemplateRoot < Mustache
10
+
11
+ include Sbuilder::Utils::MyLogger # mix logger
12
+ PROGNAME = nil
13
+
14
+ extend Forwardable # for easy delegation
15
+ def_delegators :reader,
16
+ :get_template,
17
+ :controller
18
+
19
+ attr_reader :reader
20
+ # ------------------------------------------------------------------
21
+ # @!group Constructor && config
22
+ #
23
+
24
+ def initialize( reader, options={} )
25
+
26
+ # inject reader
27
+ #@reader = Sbuilder::TemplateReader.new( options )
28
+ @reader = reader
29
+
30
+ @logger = getLogger( PROGNAME, options )
31
+ @logger.info( "#{__method__} created" )
32
+
33
+ end
34
+
35
+ # @!endgroup
36
+
37
+ # ------------------------------------------------------------------
38
+ # @!group Mustache extenstion points
39
+
40
+ # method used by mustache framework - delegate to 'get_partial',
41
+ # which must be implemented by concrete child class
42
+
43
+ def partial(name)
44
+ @logger.debug( "#{__method__} name=#{name}" )
45
+
46
+ # return resolve_partial_direct(name[2..-1]) if name[0..1] == '!!'
47
+ # get_partial( resolve_partial_name(name) )
48
+ get_partial( name )
49
+ end
50
+
51
+ # @!endgroup
52
+
53
+ # ------------------------------------------------------------------
54
+ # @!group Services offered to concrete sub-classes
55
+
56
+
57
+ # Is template extension point?
58
+ #
59
+ # @param template_name [String] name of template to check
60
+ #
61
+ def is_extension_point( template_name )
62
+ controller.is_extension_point( template_name )
63
+ end
64
+
65
+
66
+ # @!endgroup
67
+
68
+
69
+ end # class
70
+
71
+ end
@@ -1,41 +1,55 @@
1
1
 
2
2
  module Sbuilder
3
3
 
4
- class ParamSet
4
+ class ParamSet < ParamSetRoot
5
5
 
6
- attr_reader :parameters # array of parameters:Parameter
6
+ # attr_reader :parameters # array of parameters:Parameter
7
7
 
8
8
  # ------------------------------------------------------------------
9
9
  # mixer
10
- PROGNAME = "ParamSet" # progname for logger
10
+ PROGNAME = nil # progname for logger default class name
11
11
  include Sbuilder::Utils::MyLogger # mix logger
12
12
 
13
13
 
14
14
  # ------------------------------------------------------------------
15
15
  # constrcutore
16
16
  def initialize( options = {} )
17
+ super( options )
17
18
  @logger = getLogger( PROGNAME, options )
18
19
  @logger.debug( "#{__method__} initialized" )
19
- @parameters = []
20
+ # @parameters = []
20
21
  end
21
22
 
22
23
  def to_s
23
24
  "#{getId}"
24
25
  end
25
26
 
26
- # normally resolve 'parameter' sub-classes may override
27
+ # normally resolve 'parameter' sub-classes may override ie. to
28
+ # include also response parameters to the list of parameters to
29
+ # resolve.
27
30
  def parametersToResolve
28
31
  parameters
29
32
  end
30
33
 
31
- # ------------------------------------------------------------------
32
- # builder
33
- def addParameter( param )
34
- parameters << param
35
- self
34
+ # @return [Boolean] true is some of of 'parametersToResolve'
35
+ # unsersolved. Uses 'resolveReference' to resolve a parameter, if
36
+ # parameter implements this method.
37
+ def resolveNeeded( controller )
38
+ # TODO - check parametersToResolve
39
+ # return true
40
+ unresolved = parametersToResolve.select { |p| !( p.isResolved || p.respond_to?(:resolveReference) && p.resolveReference(controller.model)) }
41
+ needed = unresolved.any?
42
+ @logger.debug "#{__method__}: #{getId} resolve needed=#{needed}, unresolved=#{unresolved.map {|u| u.name}.join(',')}, parametersToResolve=#{parametersToResolve.map{|p| p.name }.join(',')}" if @logger.debug?
43
+ needed
36
44
  end
37
45
 
38
46
  # ------------------------------------------------------------------
47
+ # builder
48
+ # def addParameter( param )
49
+ # parameters << param
50
+ # self
51
+ # end
52
+
39
53
  # identifier for finding domain matche
40
54
 
41
55
  def matchesWithParamSet( matcher )
@@ -49,8 +63,9 @@ module Sbuilder
49
63
 
50
64
  def doGetId
51
65
  msg = "Sub class should implement doGetId -method"
52
- @logger.error( "#{__method__} #{msg}" )
53
- raise NoMethodError.new( msg )
66
+ @logger.error( "#{__method__} #{msg}" )
67
+ return msg
68
+ # raise NoMethodError.new( msg )
54
69
  end
55
70
 
56
71
  # ------------------------------------------------------------------
@@ -58,14 +73,14 @@ module Sbuilder
58
73
 
59
74
 
60
75
  # return hash for generation phase, false if no paramteers
61
- def parameter_definitions( model )
62
- arra = parameters.map.with_index do |p,i|
76
+ def parameter_definitions( model, paramArray=parameters )
77
+ arra = paramArray.map.with_index do |p,i|
63
78
  # puts "p=#{p}"
64
79
  parameter_def = p.parameter_definition( model )
65
80
  # puts "parameter_def=#{parameter_def}"
66
81
  parameter_def[:parameter_name] = ParamSet.cleanUpName( parameter_def[:parameter_name] )
67
82
 
68
- parameter_def[:_comma] = (i < parameters.length-1 ? "," : "" ) # empty string for last element
83
+ parameter_def['_comma'] = (i < paramArray.length-1 ? "," : "" ) # empty string for last element
69
84
  parameter_def
70
85
  # {
71
86
  # :name => p.name,
@@ -5,7 +5,7 @@ module Sbuilder
5
5
 
6
6
  # ------------------------------------------------------------------
7
7
  # mixer
8
- PROGNAME = "ParamSet_Db" # progname for logger
8
+ PROGNAME = nil # progname for logger default class name
9
9
  include Sbuilder::Utils::MyLogger # mix logger
10
10
 
11
11
  # ------------------------------------------------------------------
@@ -10,7 +10,7 @@ module Sbuilder
10
10
 
11
11
  # ------------------------------------------------------------------
12
12
  # mixer
13
- PROGNAME = "ParamSet_Def" # progname for logger
13
+ PROGNAME = nil # progname for logger default class name
14
14
  include Sbuilder::Utils::MyLogger # mix logger
15
15
 
16
16
  # ------------------------------------------------------------------
@@ -49,6 +49,11 @@ module Sbuilder
49
49
  @isArray = isArray
50
50
  self
51
51
  end
52
+
53
+ # @return [Boolean ] false should not be intepreted as a function
54
+ def isFunction
55
+ false
56
+ end
52
57
 
53
58
 
54
59
 
@@ -0,0 +1,39 @@
1
+ module Sbuilder
2
+
3
+
4
+ class ParamSetDefFunc < ParamSetDef
5
+
6
+ PROGNAME = nil # progname for logger default class name
7
+ include Sbuilder::Utils::MyLogger # mix logger
8
+
9
+ # ------------------------------------------------------------------
10
+ # @!group construct && configure
11
+
12
+ def initialize( options={} )
13
+ super( options )
14
+ @logger = getLogger( PROGNAME, options )
15
+ @logger.debug( "#{__method__} initialized" )
16
+
17
+ end
18
+ # @!endgroup
19
+
20
+ # @return [Boolean ] true should not be intepreted as a function
21
+ # (Overrides paranent method)
22
+ def isFunction
23
+ true
24
+ end
25
+
26
+ # @return [Parameter:Array] all but last element parameters[0..-2]
27
+ def domainParameters
28
+ parameters[0..-2]
29
+ end
30
+
31
+ # @return [Parameter:Array] last element as an array [parameters[-1]]
32
+ def rangeParameters
33
+ [parameters[-1]]
34
+ end
35
+
36
+
37
+ end
38
+
39
+ end
@@ -1,17 +1,33 @@
1
1
 
2
2
  module Sbuilder
3
3
 
4
- # interface paramter set (identified by path+operations)
4
+ ##
5
+ # Interface paramter set model interfaces. An interface is
6
+ # identified by path+operations (e.g. /customer(get) ).
7
+ #
8
+ # Method #parameters return input to the interface, and #response
9
+ # -method output from the interface service.
10
+ #
11
+ #
5
12
  class ParamSet_If < ParamSet
6
13
 
7
14
  attr_reader :path # REST path
8
15
  attr_reader :operation # REST path
9
- attr_reader :response # returned from interface
16
+
17
+ # @attr [ParamSet] response parameter set
18
+ attr_reader :response
19
+
20
+ # @attr [Boolean] infrastructureService true when generate support
21
+ # to return response from interface service.
10
22
  attr_reader :infrastructureService # default 'false'
11
23
 
24
+ # @attr [Boolean] interfaceService true when generates interface
25
+ # process
26
+ attr_reader :interfaceService
27
+
12
28
  # ------------------------------------------------------------------
13
29
  # mixer
14
- PROGNAME = "ParamSet_If" # progname for logger
30
+ PROGNAME = nil # progname for logger default class name
15
31
  include Sbuilder::Utils::MyLogger # mix logger
16
32
 
17
33
  # ------------------------------------------------------------------
@@ -21,15 +37,12 @@ module Sbuilder
21
37
  @logger = getLogger( PROGNAME, options )
22
38
  @logger.debug( "#{__method__} initialized" )
23
39
  @response = nil
24
- @infrastructureService = false
40
+
41
+ # default: generate interface processes, no support for response return
42
+ setInterfaceService( true )
43
+ setInfrastructureService( false )
25
44
  end
26
45
 
27
- # # normally resolve 'parameter', however in my case resolve also responses
28
- # def parametersToResolve
29
- # return parameters + ( @response ? @response.parameters : [])
30
- # end
31
-
32
-
33
46
  # ------------------------------------------------------------------
34
47
  # configure
35
48
 
@@ -43,11 +56,29 @@ module Sbuilder
43
56
  self
44
57
  end
45
58
 
59
+ ##
60
+ # Rendering generates interface procesess when true
61
+ #
62
+ def setInterfaceService( interfaceService )
63
+ @interfaceService = interfaceService
64
+ self
65
+ end
66
+
67
+ ##
68
+ # Rendering generates support to return values from infrastructure
69
+ # service.
46
70
  def setInfrastructureService( infrastructureService )
47
71
  @infrastructureService = infrastructureService
48
72
  self
49
73
  end
50
74
 
75
+ # @return [Parameter:Array] parameters including
76
+ # response.parameters, if any
77
+ def parametersToResolve
78
+ parameters + (response.nil? ? [] : response.parameters)
79
+ end
80
+
81
+
51
82
  # ------------------------------------------------------------------
52
83
  # setIdentity
53
84
 
@@ -63,6 +94,10 @@ module Sbuilder
63
94
  "#{path}(#{operation})"
64
95
  end
65
96
 
97
+ def isArray
98
+ return false
99
+ end
100
+
66
101
  end
67
102
 
68
103
  end
@@ -13,18 +13,32 @@ module Sbuilder
13
13
 
14
14
 
15
15
  # ------------------------------------------------------------------
16
- # constrcutore
16
+ # @!group Construct && configure
17
+
17
18
  def initialize( options = {} )
19
+ super( options )
18
20
  end
19
21
 
20
22
 
21
- # ------------------------------------------------------------------
23
+ ##
22
24
  # class method configure
23
-
25
+ #
24
26
  # @param configuration [Hash] properties to configure
25
27
  def self.configure( configuration )
26
28
  end
27
29
 
30
+ ##
31
+ # Instance configuration
32
+ #
33
+ # @param [Hash] configuration for object instance, defined in
34
+ # sbuilder.yaml
35
+ #
36
+ def doConfigure( configuration )
37
+ end
38
+
39
+ # @!endgroup
40
+
41
+
28
42
  # ------------------------------------------------------------------
29
43
  # Loader methods
30
44
 
@@ -138,20 +152,23 @@ module Sbuilder
138
152
 
139
153
  # create set && configure param set for a defintion
140
154
  paramSet = facade.newDefinition( defineKey, definedDoc['type'] == 'array' )
155
+ logger.info "#{__method__} create new definition paramSet=#{paramSet}, isArray=#{paramSet.isArray}"
141
156
 
142
157
  # collect
143
158
  definitions << paramSet
144
159
 
145
- # defines reference
160
+ # defines reference $ref of items.$ref
146
161
  if hasRef( definedDoc ) then
147
162
  # case paramter set is a wrapper - most likely an array
148
- reference_parameter( paramSet, defineKey, getRefDocumentName( definedDoc ), definedDoc['type'] )
163
+ # reference_parameter( paramSet, defineKey, getRefDocumentName( definedDoc ), definedDoc['type'] )
164
+ swagger_parameter = facade.newParameterReference( defineKey, getRefDocumentName( definedDoc ), definedDoc['type'] == 'array' )
165
+ facade.addParameter( paramSet, swagger_parameter )
149
166
 
150
167
  else
151
168
 
152
169
  # defines onw attributes
153
170
  expandedDocs = expand_definedDocs( definedDoc, swagger_hash )
154
- # puts " defineKey=#{defineKey} --> expandedDocs=#{expandedDocs}"
171
+ logger.debug "#{__method__} defineKey=#{defineKey} --> expandedDocs=#{expandedDocs}"
155
172
 
156
173
  # iterate array of [ { <name> = { "type"=>.., <format> =>..}, <name> => ..}, ... ]
157
174
  expandedDocs.each do |expandedDoc|
@@ -159,9 +176,14 @@ module Sbuilder
159
176
  expandedDoc.each do |parameterName,parameterProps|
160
177
  logger.debug( "#{__method__} {op}-parameterName->#{parameterName}, parameterProps=>#{parameterProps}" )
161
178
  if hasRef( parameterProps ) then
162
- reference_parameter( paramSet, parameterName, getRefDocumentName( parameterProps ), parameterProps['type'] )
179
+ # reference_parameter( paramSet, parameterName, getRefDocumentName( parameterProps ), parameterProps['type'] )
180
+ swagger_parameter = facade.newParameterReference( parameterName, getRefDocumentName( parameterProps ), parameterProps['type'] == 'array' )
181
+ facade.addParameter( paramSet, swagger_parameter )
182
+
163
183
  else
164
- simple_parameter( paramSet, parameterName, parameterProps['type'] )
184
+ # simple_parameter( paramSet, parameterName, parameterProps['type'] )
185
+ swagger_parameter = facade.newParameter( parameterName, parameterProps['type'] == 'array' )
186
+ facade.addParameter( paramSet, swagger_parameter )
165
187
  end
166
188
  end
167
189
  end
@@ -190,7 +212,7 @@ module Sbuilder
190
212
 
191
213
  # New interface operation '/path(op) & access response operation
192
214
  interfaceParamSet = facade.newInterface( path, op )
193
- paramSetResponse = interfaceParamSet.response
215
+ # paramSetResponse = interfaceParamSet.response
194
216
 
195
217
  logger.info( "#{__method__} created interfaceParamSet=#{interfaceParamSet.getId}" )
196
218
  logger.debug( "#{__method__} created interfaceParamSet.getId=#{interfaceParamSet.getId}, opdef=#{opdef}" )
@@ -206,9 +228,16 @@ module Sbuilder
206
228
  if parameter['schema'] then
207
229
  # in='body' => schema defined
208
230
  defintionReferenceName = getReferencedDefinitionName( parameter['schema'], swagger_hash )
209
- reference_parameter( interfaceParamSet, parameter['name'], defintionReferenceName )
231
+ parameterType = parameter['schema']['type']
232
+
233
+ # reference_parameter( interfaceParamSet, parameter['name'], defintionReferenceName, parameterType )
234
+ swagger_parameter = facade.newParameterReference( parameter['name'], defintionReferenceName, parameterType == 'array' )
235
+ facade.addParameter( interfaceParamSet, swagger_parameter )
236
+
210
237
  elsif parameter['name']
211
- simple_parameter( interfaceParamSet, parameter['name'], parameter['type'] ) if parameter['name']
238
+ # simple_parameter( interfaceParamSet, parameter['name'], parameter['type'] ) if parameter['name']
239
+ swagger_parameter = facade.newParameter( parameter['name'], parameter['type'] == 'array' )
240
+ facade.addParameter( interfaceParamSet, swagger_parameter )
212
241
  else
213
242
  msg = "Empty parameter definition on #{path}/#{op} "
214
243
  logger.error( "#{__method__} #{msg}" )
@@ -226,8 +255,9 @@ module Sbuilder
226
255
  if response['schema'] then
227
256
  defintionReferenceName = getReferencedDefinitionName( response['schema'], swagger_hash )
228
257
  logger.debug( "#{__method__} defintionReferenceName=#{defintionReferenceName}, op=#{op}, status_code=#{status_code}, response=#{response}" )
229
- reference_parameter( paramSetResponse, "status_#{status_code}", defintionReferenceName, response['schema']['type'] )
230
-
258
+ # reference_parameter( paramSetResponse, "status_#{status_code}", defintionReferenceName, response['schema']['type'] )
259
+ swagger_parameter = facade.newParameterReference( "status_#{status_code}", defintionReferenceName, response['schema']['type'] == 'array' )
260
+ facade.addResponseParameter( interfaceParamSet, swagger_parameter )
231
261
  else
232
262
  logger.debug( "#{path}-#{op}-#{status_code}: no response data for response #{response}" )
233
263
  # response object
@@ -243,25 +273,25 @@ module Sbuilder
243
273
  # ------------------------------------------------------------------
244
274
  # Create parameters && add to param set
245
275
 
246
- # process simple (i.e. non body ) parameter
247
- def simple_parameter( paramSet, name, parameterType )
276
+ # # process simple (i.e. non body ) parameter
277
+ # def simple_parameter( paramSet, name, parameterType )
248
278
 
249
- swagger_parameter = facade.newParameter( name, parameterType == 'array' )
250
- # add to parameter set
251
- paramSet.addParameter( swagger_parameter )
252
- end
279
+ # swagger_parameter = facade.newParameter( name, parameterType == 'array' )
280
+ # # add to parameter set
281
+ # paramSet.addParameter( swagger_parameter )
282
+ # end
253
283
 
254
- # process simple (i.e. non body ) parameter
255
- def reference_parameter( paramSet, name, defintionReferenceName, parameterType="string" )
284
+ # # process simple (i.e. non body ) parameter
285
+ # def reference_parameter( paramSet, name, defintionReferenceName, parameterType="string" )
256
286
 
257
- swagger_parameter = facade.newParameterReference( name, defintionReferenceName, parameterType == 'array' )
287
+ # swagger_parameter = facade.newParameterReference( name, defintionReferenceName, parameterType == 'array' )
258
288
 
259
- logger.info( "#{__method__} param set =#{paramSet.getId}, parameter=#{swagger_parameter.getName}, parameter=#{swagger_parameter.reference}" )
289
+ # logger.info( "#{__method__} param set =#{paramSet.getId}, parameter=#{swagger_parameter.getName}, parameter=#{swagger_parameter.reference}, parameterType=#{parameterType}" )
260
290
 
261
- # add to parameter set
262
- paramSet.addParameter( swagger_parameter )
291
+ # # add to parameter set
292
+ # paramSet.addParameter( swagger_parameter )
263
293
 
264
- end
294
+ # end
265
295
 
266
296
 
267
297
  # ------------------------------------------------------------------