acos_jekyll_openapi_helper 1.4.5 → 1.6.0

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: e14565e520d910b4fb71d19d57b32315fdf2ea1592a932fe98c12c8c0e0362fe
4
- data.tar.gz: 87e9f0168e68274c41387e1148fa9e60371ff10e15300ca05fde77f2534b5a16
3
+ metadata.gz: 403ad932887e7f941556a76ef2e1e6b6a889f2bc8e3fb82fe6017a5f0bb8e89c
4
+ data.tar.gz: d72b874f04ec17c65517bacea4d39159c83d2a5141c32dfebaa557491f45c8c1
5
5
  SHA512:
6
- metadata.gz: f2b31b4d1e8c4fb37cccaa3924fb1a15341b39bed0d71c9996cb4396f6f151071e188f0d56635d6ddb708669ff2f59aa00e36d8176c3ffcd8686aa06122fc0e8
7
- data.tar.gz: e094bbbcef3b62db93109913245944d0940dc8e8689f5ea3a3a20d52fa5d14d8a269a2169ac5086ab1b98e13fe59c668b04b9ee363d1b3ea9191f1783f5d82f7
6
+ metadata.gz: 95b4553ff5b42116de09c47a69caae0e755f826b74929fd66295df68f7ca45400d0b35be78d538ee2a7b196bbf383e0f4599cfa0290c776b10739647a07bb45c
7
+ data.tar.gz: d3a64d49e31098a179c8e038bbf597c51c81c33faf72e71202cc1a0f3a44f7b4c8ca7b49453d69897ee16f7b2be23a969bffad653288ab350e91bf126aea72c1
@@ -11,8 +11,16 @@ class AcosOpenApiHelper
11
11
  engine.generate
12
12
  end
13
13
 
14
- def self.generate_pages_from_data(datafolder, basePath, output_path)
14
+ def self.generate_pages_from_data(datafolder, basePath, output_path, only_files = [])
15
15
  json_files = Dir["%s/*.json" % datafolder]
16
+ wanted = Array(only_files).map { |name| File.basename(name.to_s.strip) }.reject(&:empty?)
17
+ unless wanted.empty?
18
+ json_files = json_files.select { |jf| wanted.include?(File.basename(jf)) }
19
+ missing = wanted - json_files.map { |jf| File.basename(jf) }
20
+ unless missing.empty?
21
+ raise "No swagger JSON matched: #{missing.join(', ')} in #{datafolder}"
22
+ end
23
+ end
16
24
  json_files.each do | jf |
17
25
  puts "Generating pages based on: %s" % jf
18
26
  generate_pages(jf, basePath, output_path)
@@ -59,111 +67,18 @@ class AcosOpenApiHelper::PageEngine
59
67
  docFile = docTitle.gsub(/\+|\s+|{|}|\//, "_").downcase
60
68
  puts "Document title : %s" % docTitle
61
69
  sidebar = "%s_sidebar" % docFile
62
- menu = AcosOpenApiHelper::SidebarMenu.new()
63
-
64
- if File.exists?("%s/%s_index.md" % [@output_path, docFile] )
65
- _indexMenu = AcosOpenApiHelper::MenuItem.new("Overview %s " % docTitle, "%s_index" % docFile)
66
- menu.add(_indexMenu)
67
- cnt = cnt + 1
68
- else
69
- puts "No index file found for %s" % docFile
70
- end
71
70
 
72
71
  @data['paths'].each do |path|
73
- _path = path[0] #path of swagger method
74
- _methods = @data['paths'][_path]
75
- #(path, basePath, output_path, swaggerfile, sidebar, docFile, component)
72
+ _path = path[0]
76
73
  writer = AcosOpenApiHelper::PageCreator.new(_path, @basePath, @output_path, @swaggerfile, sidebar, docFile, _components)
77
74
  writer.write
78
- _permalink = AcosOpenApiHelper::PermalinkGenerator.create(_path, @swaggerfile)
79
- _menuItem = AcosOpenApiHelper::MenuItem.new(_path, _permalink)
80
- menu.add(_menuItem)
81
75
  cnt = cnt + 1
82
76
  end
83
- # Adding component page for models
84
- #createComponents(basePath, title, sidebar, swaggerfile, docFile)
85
77
  AcosOpenApiHelper::PageCreator.createComponents(@basePath, docTitle, sidebar, @swaggerfile, docFile, _components)
86
- _componentMenu = AcosOpenApiHelper::MenuItem.new("%s Models" % docTitle, "%s_components" % docFile)
87
- menu.add(_componentMenu)
88
78
  cnt = cnt + 1
89
79
 
90
80
  puts "Done generating %s pages..." % cnt
91
- puts "Writing menu"
92
- menu.write("%s/_data/sidebars" % @basePath, sidebar, docTitle)
93
- end
94
- end
95
-
96
- class AcosOpenApiHelper::SidebarMenu
97
- @@entries = Array.new
98
- #attr_accessor :title, :url
99
-
100
- def self.all_entries
101
- @@entries
102
- end
103
-
104
- def add(entry)
105
- @@entries.push(entry)
106
- end
107
-
108
-
109
- def initialize()
110
- # @title = title
111
- # @url = url
112
- #@@entries << self
113
- end
114
-
115
- def write (output_path, name, menuTitle)
116
- #no spaces in filename ofr sidebar.yml
117
- name = name.gsub(/\s+|{|}|\/|\+/, "_").downcase
118
- puts "Name of file %s" % [name]
119
- _standardLines = [
120
- "# THIS PAGE IS GENERATED. ANY CHANGES TO PAGE WILL POTENTIALLY BE OVERWRITTEN.",
121
- "# This is your sidebar TOC. The sidebar code loops through sections here and provides the appropriate formatting.",
122
- "entries:",
123
- "- title: sidebar",
124
- " # product: Documentation",
125
- " # version: 1.0",
126
- " folders:",
127
- " - title: %s" % menuTitle,
128
- " output: web",
129
- " type: frontmatter",
130
- " folderitems: "
131
- ]
132
- puts "Writing menu with length: %s" % @@entries.length
133
- @@entries.each do | item |
134
- #puts "Entry: %s, url: %s" % [item.title, item.url]
135
- _standardLines << " - title: %s" % item.title
136
- _standardLines << " url: /%s.html" % item.url
137
- _standardLines << " output: web, pdf"
138
- end
139
-
140
- # _standardLines << " - title: %s" % "Models"
141
- # _standardLines << " url: /%s.html" % "userapi_components"
142
- # _standardLines << " output: web, pdf"
143
- # File.open("%s/%s/%s/%s.%s" % [@basePath, "pages", "swagger", @permalink, "md"], "w+") do |f|
144
- # f.puts(@lines)
145
- # end
146
- puts "Writing menu file for %s at %s" % [name, output_path]
147
- File.open("%s/%s.%s" % [output_path, name, "yml"], "w+") do | f |
148
- f.puts(_standardLines)
149
- end
150
-
151
- @@entries.clear
152
- end
153
-
154
- end
155
-
156
- class AcosOpenApiHelper::MenuItem
157
- def initialize(title, url)
158
- @title = title
159
- @url = url
160
- end
161
-
162
- def title
163
- @title
164
- end
165
- def url
166
- @url
81
+ puts "Sidebar is owned by overlay compose; gem does not write sidebar YAML."
167
82
  end
168
83
  end
169
84
 
@@ -172,6 +87,9 @@ class AcosOpenApiHelper::PermalinkGenerator
172
87
  @swaggerfileBase = File.basename(swaggerfile, ".*")
173
88
  @permalinkBase = "%s_%s" % [@swaggerfileBase, path]
174
89
  @permalink = @permalinkBase.gsub(/\+|\s+|{|}|\//, "_").downcase
90
+ unless @permalink =~ /\A[a-z0-9_-]+\z/
91
+ raise "Unsafe permalink: #{@permalink}"
92
+ end
175
93
  return @permalink
176
94
  end
177
95
 
@@ -185,6 +103,9 @@ class AcosOpenApiHelper::FileNameGenerator
185
103
  def self.create(path, docFile)
186
104
  @docFileBase = "%s_%s" % [docFile, path]
187
105
  @docFileName = @docFileBase.gsub(/\+|\s+|{|}|\//, "_").downcase
106
+ unless @docFileName =~ /\A[a-z0-9_-]+\z/
107
+ raise "Unsafe generated filename: #{@docFileName}"
108
+ end
188
109
  return @docFileName
189
110
  end
190
111
 
@@ -195,7 +116,6 @@ end
195
116
 
196
117
  class AcosOpenApiHelper::PageCreator
197
118
  def initialize(path, basePath, output_path, swaggerfile, sidebar, docFile, component)
198
- # puts "Initialize intput %s, %s, %s, %s" % [path, output_path, swaggerfile, sidebar]
199
119
  @path = path
200
120
  @output_path = output_path
201
121
  @swaggerfile = swaggerfile
@@ -221,7 +141,8 @@ class AcosOpenApiHelper::PageCreator
221
141
  "swagger_components: %s" % component,
222
142
  "components_file: %s" % docFile,
223
143
  "---",
224
- "{\% include swagger_json/get_path.md \%}"
144
+ "{\% include swagger_json/get_path.md \%}",
145
+ "{\% include swagger_json/overlay_slot.md slot=\"after_page\" \%}"
225
146
  ]
226
147
  end
227
148
 
@@ -233,6 +154,9 @@ class AcosOpenApiHelper::PageCreator
233
154
 
234
155
  def self.createComponents(basePath, title, sidebar, swaggerfile, docFile, componentsKey)
235
156
  swaggerfileName = File.basename(swaggerfile, ".*")
157
+ unless docFile =~ /\A[a-z0-9_-]+\z/
158
+ raise "Unsafe generated filename: #{docFile}"
159
+ end
236
160
  contentLines = [
237
161
  "---",
238
162
  "title: %s Models" % title,
@@ -258,4 +182,4 @@ class AcosOpenApiHelper::PageCreator
258
182
  f.puts(contentLines)
259
183
  end
260
184
  end
261
- end
185
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acos_jekyll_openapi_helper
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.5
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Acos AS
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-28 00:00:00.000000000 Z
11
+ date: 2026-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json
@@ -30,13 +30,12 @@ executables: []
30
30
  extensions: []
31
31
  extra_rdoc_files: []
32
32
  files:
33
- - bin/start.rb
34
33
  - lib/acos_jekyll_openapi.rb
35
34
  homepage: https://rubygems.org/gems/acos_jekyll_openapi_helper
36
35
  licenses:
37
36
  - MIT
38
37
  metadata: {}
39
- post_install_message:
38
+ post_install_message:
40
39
  rdoc_options: []
41
40
  require_paths:
42
41
  - lib
@@ -51,8 +50,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
50
  - !ruby/object:Gem::Version
52
51
  version: '0'
53
52
  requirements: []
54
- rubygems_version: 3.1.2
55
- signing_key:
53
+ rubygems_version: 3.4.20
54
+ signing_key:
56
55
  specification_version: 4
57
56
  summary: Open API json file helper
58
57
  test_files: []
data/bin/start.rb DELETED
@@ -1,8 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'acos_jekyll_openapi'
4
- AcosOpenApiHelper.generate_pages_from_data(
5
- "/mnt/c/Kode/github/Acos.Integration.Documentation/_data/swagger",
6
- "/mnt/c/Kode/github/Acos.Integration.Documentation",
7
- "/mnt/c/Kode/github/Acos.Integration.Documentation/pages/swagger"
8
- )