oas_core 0.5.1 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 202ef79c5565fcd8d1c8443267f718d006dc8daa4abb8dd50b08863e8c06af80
4
- data.tar.gz: 0b0c223a44e635e63f28e4e0e268ebba99efde363d2f83fad7446af3a299d8f6
3
+ metadata.gz: 8396df67f2123727d598bd1860f44b8595776b8564ad39b8c788bcfad839a522
4
+ data.tar.gz: 4e6525b5259d2b105edfaa094e04e4ee778453d5500208f692849c165a340596
5
5
  SHA512:
6
- metadata.gz: 2dcd7323e5ce3566d7292790bff07e84a33a608c181d70cf9bbf822cb15a362ea98dcdc85496145a5e1187d3a1b765a52e6a51e4215cc4da7ec40bce9c04ad5d
7
- data.tar.gz: 871a04fe56856868ce4d8927ddfd62e3a20dcd8cf87af11e276ccc7c132d2884876edeaf536fee251b5e57f6a4b5f2bc9a4c31bde6459fc5a4235426782fa573
6
+ metadata.gz: fab7a5e69cc18c3745d9780ccfee5e9ab0ada24515efde300c7dbdce04f19f68331d394506da5fb71f1b6299ed74f6ce19913c513440c0ab5c1909cd45f20f8b
7
+ data.tar.gz: 2e7ccf626a4c5aaeba13f9930d0853605bca4060c69977a50488df36c92dbd79059751c1fc63682cbeadbc7fc819f3537ab3442462b385dc4ecbfdc70657be08
@@ -31,8 +31,7 @@ module OasCore
31
31
 
32
32
  def extract_summary(oas_route:)
33
33
  summary_tag = oas_route.tags(:summary).first
34
- summary_tag&.text || generate_crud_name(oas_route.method_name,
35
- oas_route.controller.downcase) || "#{oas_route.verb} #{oas_route.path}"
34
+ summary_tag&.text || generate_crud_name(oas_route.method_name) || "#{oas_route.verb} #{oas_route.path}"
36
35
  end
37
36
 
38
37
  def extract_operation_id(oas_route:)
@@ -74,21 +73,14 @@ module OasCore
74
73
  end
75
74
  end
76
75
 
77
- def generate_crud_name(method, controller)
78
- controller_name = controller.to_s.underscore.humanize.downcase.pluralize
79
-
80
- case method.to_sym
81
- when :index
82
- "List #{controller_name}"
83
- when :show
84
- "View #{controller_name.singularize}"
85
- when :create
86
- "Create new #{controller_name.singularize}"
87
- when :update
88
- "Update #{controller_name.singularize}"
89
- when :destroy
90
- "Delete #{controller_name.singularize}"
91
- end
76
+ def generate_crud_name(method)
77
+ {
78
+ index: 'List',
79
+ show: 'View',
80
+ create: 'Create',
81
+ update: 'Update',
82
+ destroy: 'Delete'
83
+ }.fetch(method.to_sym)
92
84
  end
93
85
  end
94
86
  end
@@ -43,6 +43,8 @@ module OasCore
43
43
  private
44
44
 
45
45
  def determine_common_errors(oas_route, security)
46
+ # TODO: this is Rails focus solution.
47
+ # We need a framework agnostic solution or simple remove and give this responsability to adapters.
46
48
  common_errors = []
47
49
  common_errors.push(:unauthorized, :forbidden, :internal_server_error) if security
48
50
 
@@ -14,9 +14,9 @@ module OasCore
14
14
 
15
15
  attr_reader :servers, :tags, :security_schema, :response_body_of_default
16
16
 
17
- def initialize
18
- @info = Spec::Info.new
19
- @servers = default_servers
17
+ def initialize(**args)
18
+ @info = args.fetch(:info, Spec::Info.new)
19
+ @servers = args.fetch(:servers, default_servers)
20
20
  @tags = []
21
21
  @swagger_version = '3.1.0'
22
22
  @default_tags_from = :namespace
@@ -56,7 +56,7 @@ module OasCore
56
56
  end
57
57
 
58
58
  def default_servers
59
- [Spec::Server.new(url: 'http://localhost:3000', description: 'Rails Default Development Server')]
59
+ [Spec::Server.new(url: 'http://localhost:3000', description: 'Development Server')]
60
60
  end
61
61
 
62
62
  def servers=(value)
@@ -67,14 +67,6 @@ module OasCore
67
67
  @tags = value.map { |t| Spec::Tag.new(name: t[:name], description: t[:description]) }
68
68
  end
69
69
 
70
- def excluded_columns_incoming
71
- %i[id created_at updated_at deleted_at]
72
- end
73
-
74
- def excluded_columns_outgoing
75
- []
76
- end
77
-
78
70
  def response_body_of_default=(value)
79
71
  raise ArgumentError, 'response_body_of_default must be a String With a valid object' unless value.is_a?(String)
80
72
 
@@ -2,9 +2,7 @@
2
2
 
3
3
  module OasCore
4
4
  class OasRoute
5
- # TODO: Check what variables are in use and remove the ones that are not.
6
- attr_accessor :controller_class, :controller_action, :controller, :controller_path, :method_name, :verb, :path,
7
- :docstring, :source_string
5
+ attr_accessor :controller, :method_name, :verb, :path, :docstring, :source_string
8
6
  attr_writer :tags
9
7
 
10
8
  def initialize(attributes = {})
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module OasCore
4
- VERSION = '0.5.1'
4
+ VERSION = '0.5.3'
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oas_core
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - a-chacon