{"action":"opened","issue":{"url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/1836","labels_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/1836/labels{/name}","comments_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/1836/comments","events_url":"https://api.github.com/repos/swagger-api/swagger-codegen/issues/1836/events","html_url":"https://github.com/swagger-api/swagger-codegen/issues/1836","id":125421564,"number":1836,"title":"[Java Client] Authentication not correctly added","user":{"login":"hiveship","id":6461306,"avatar_url":"https://avatars.githubusercontent.com/u/6461306?v=3","gravatar_id":"","url":"https://api.github.com/users/hiveship","html_url":"https://github.com/hiveship","followers_url":"https://api.github.com/users/hiveship/followers","following_url":"https://api.github.com/users/hiveship/following{/other_user}","gists_url":"https://api.github.com/users/hiveship/gists{/gist_id}","starred_url":"https://api.github.com/users/hiveship/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hiveship/subscriptions","organizations_url":"https://api.github.com/users/hiveship/orgs","repos_url":"https://api.github.com/users/hiveship/repos","events_url":"https://api.github.com/users/hiveship/events{/privacy}","received_events_url":"https://api.github.com/users/hiveship/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-01-07T15:57:04Z","updated_at":"2016-01-07T15:57:04Z","closed_at":null,"body":"I am writing a specification for my API and I've found a problem in the Java client generated (I generate my with using the Swagger Editor option > Generate Java Client).\r\n\r\nMy Swagger files contains:\r\n```yaml\r\nswagger: \"2.0\"\r\ninfo:\r\n  version: 1.0.0\r\n  title: Application Server\r\n  description: The API to communicate with the Application Server\r\n  termsOfService: http://foo.com/terms\r\n  contact:\r\n    name: Foo Company\r\n    email: contact@foo.com\r\n    url: http://foo.com\r\n  license:\r\n    name: Licence\r\n    url: http://\r\n    \r\nhost: localhost:8080\r\n\r\nbasePath: /foo\r\n\r\nschemes:\r\n  - http\r\n  \r\nconsumes:\r\n  - application/json\r\n  - application/xml\r\n  \r\nproduces:\r\n  - application/json\r\n  - application/xml\r\n  \r\nsecurityDefinitions:\r\n  basicAuth:\r\n    type: basic\r\n    description: HTTP Basic Authentication. Works over `HTTP`.\r\n security:\r\n       - basicAuth: []\r\n  \r\npaths:\r\n  /:\r\n    get:\r\n      description: |\r\n        Get the general information about the nabuTalk Application Server\r\n      summary: Ping the nabuTalk Application Server.\r\n      operationId: ping\r\n      tags:\r\n        - Global\r\n      responses:\r\n        200:\r\n          description: Server information\r\n        default:\r\n          description: Server error\r\n          schema: \r\n            $ref: '#/definitions/Error'\r\n```\r\nSo I think that this file is correct to specify a HTTP Basic Authentication for the whole API.\r\n\r\nIn the Swagger Editor and the Swagger UI everything is OK, I can test my methods and it's working.\r\nBut in the Java generated client, I always got an HTTP 401 return code. It seems that the authentication is not added as a header parameter.\r\n\r\nMy Java code is:\r\n```java\r\nApiClient apiClient = Configuration.getDefaultApiClient();\r\napiClient.setUsername(\"username\");\r\napiClient.setPassword(\"password\");\r\n\r\nGlobalApi defaultApi = new GlobalApi(apiClient);\r\ndefaultApi.ping();\r\n```\r\n\r\nbut if I modify my Swagger file as below:\r\n```yaml\r\nswagger: \"2.0\"\r\ninfo:\r\n  version: 1.0.0\r\n  title: Application Server\r\n  description: The API to communicate with the Application Server\r\n  termsOfService: http://foo.com/terms\r\n  contact:\r\n    name: Foo Company\r\n    email: contact@foo.com\r\n    url: http://foo.com\r\n  license:\r\n    name: Licence\r\n    url: http://\r\n    \r\nhost: localhost:8080\r\n\r\nbasePath: /foo\r\n\r\nschemes:\r\n  - http\r\n  \r\nconsumes:\r\n  - application/json\r\n  - application/xml\r\n  \r\nproduces:\r\n  - application/json\r\n  - application/xml\r\n  \r\nsecurityDefinitions:\r\n  basicAuth:\r\n    type: basic\r\n    description: HTTP Basic Authentication. Works over `HTTP`.\r\n  \r\npaths:\r\n  /:\r\n    get:\r\n      security:\r\n       - basicAuth: []\r\n      description: |\r\n        Get the general information about the nabuTalk Application Server\r\n      summary: Ping the nabuTalk Application Server.\r\n      operationId: ping\r\n      tags:\r\n        - Global\r\n      responses:\r\n        200:\r\n          description: Server information\r\n        default:\r\n          description: Server error\r\n          schema: \r\n            $ref: '#/definitions/Error'\r\n```\r\nThen everything is ok !\r\n\r\nI think it's a bug ?"}}