zipmark/rspec_api_documentation

Unable to remove contact from info

vaibhavatul47 opened this issue · 1 comments

I don't want terms of service, contact, license fields in info of my api-documentation output. Why are these fields generated ? I am using open_api format for documentation.

open_api.yml

swagger: '2.0'
info:
  title: My title
  description: My API documentation
  version: 1.0.0
schemes:
- https
consumes:
- application/json
produces:
- application/json
host: ""

Produced output:

{
  "swagger": "2.0",
  "info": {
    "title": "My title",
    "description": "My API documentation",
    "termsOfService": "http://open-api.io/terms/",
    "contact": {
      "name": "API Support",
      "url": "http://www.open-api.io/support",
      "email": "support@open-api.io"
    },
    "license": {
      "name": "Apache 2.0",
      "url": "http://www.apache.org/licenses/LICENSE-2.0.html"
    },
    "version": "1.0.0"
  }
}

Expected output:

{
  "swagger": "2.0",
  "info": {
    "title": "My App",
    "description": "My API documentation",
    "version": "1.0.0"
  }
}

Temp fix:
I've monkey-patched RspecApiDocumentation::OpenApi::Info class and hardcoded the info json:

class RspecApiDocumentation::OpenApi::Info
  def as_json
    {
      title: "My App",
      description: "My API documentation",
      version: "1.0.0"
    }
  end
end

They are there because the Info node defines them as settings.

https://github.com/zipmark/rspec_api_documentation/blob/master/lib/rspec_api_documentation/open_api/info.rb

I don't use this formatter, so if you would like to PR a fix then I will gladly accept it. I also thought they were required fields but on looking at the spec they are not. That's possibly another reason why they are included.