# File lib/skeleton/serializers/swagger.rb, line 16
      def to_h
        hash = {
          swagger: '2.0',
          info: {
            title: structure.title,
            description: structure.description,
            version: structure.version,
            termsOfService: structure.terms,
            contact: {
              name: structure.contact.name,
              email: structure.contact.email,
              url: structure.contact.url
            },
            license: {
              name: structure.license.name,
              url: structure.license.url
            }
          },
          basePath: structure.base_path,
          host: structure.host,
          schemes: structure.schemes.map(&:to_s),
          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[:securityDefinitions] = {},
          hash[:security] = []
        end

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

        if structure.external_docs
          hash[:externalDocs] = structure.external_docs
        end

        hash[:paths] = {}
        structure.paths.each do |resource, path|
          hash[:paths][resource] = {}

          path.operations.each do |verb, operation|
            hash[:paths][resource][verb] = operation_to_h(operation)
          end
        end

        hash[:definitions] = {}
        structure.models.each do |name, model|
          hash[:definitions][name] = schema_to_h(model)
        end

        hash
      end