# File lib/skeleton/serializers/options.rb, line 22
      def to_h
        graph = Skeleton::Graph.new
        structure.models.each do |name, model|
          graph.register(name, dependencies_for(model))
        end

        hash = {
          consumes: structure.consumes.map(&:to_s),
          produces: structure.produces.map(&:to_s)
        }

        if structure.parameters?
          hash[:parameters] = {}
          structure.parameters.each do |name, parameter|
            hash[:parameters][name] = parameter_to_h(parameter)
          end
        end

        if structure.responses?
          hash[:responses] = {}
          structure.responses.each do |name, response|
            hash[:responses][name] = response_to_h(response)
          end
        end

        if structure.secure?
          hash[:security_definitions] = {},
          hash[:security] = []
        end

        hash[:tags] = structure.tags.map do |name, tag|
          sub = {
            name: name
          }
          sub[:description] = tag.description if tag.description?
          sub[:external_docs] = tag.external_docs if tag.external_docs?
          sub
        end

        path = structure.paths.fetch(@path) { raise(Skeleton::Error, "path '#{@path}' not found in structure") }
        hash[:operations] ||= {}
        path.operations.each do |verb, operation|
          hash[:operations][verb] = operation_to_h(operation)
        end

        hash[:definitions] ||= {}

        dependencies.to_a.each do |dep|
          graph.each_dependent_for(dep) do |name|
            hash[:definitions][name] = schema_to_h(structure.models[name])
          end
        end

        hash
      end