Class: Iron::Api::OpenapiSpec

Inherits:
Object
  • Object
show all
Defined in:
app/models/iron/api/openapi_spec.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.cache_keyObject



4
5
6
7
8
9
# File 'app/models/iron/api/openapi_spec.rb', line 4

def self.cache_key
  sources = [ ContentType, FieldDefinition, BlockDefinition ]
  latest = sources.filter_map { |model| model.maximum(:updated_at) }.max
  revisions = sources.sum(&:count)
  "iron/openapi/#{latest&.utc&.strftime('%s%6N')}-#{revisions}"
end

Instance Method Details

#to_hObject



11
12
13
14
15
16
17
18
19
# File 'app/models/iron/api/openapi_spec.rb', line 11

def to_h
  {
    openapi: "3.1.0",
    info: { title: "Iron CMS API", version: "1.0" },
    security: [ { bearerAuth: [] } ],
    paths: paths,
    components: components
  }
end