{"action":"created","issue":{"url":"https://api.github.com/repos/OAI/OpenAPI-Specification/issues/1635","repository_url":"https://api.github.com/repos/OAI/OpenAPI-Specification","labels_url":"https://api.github.com/repos/OAI/OpenAPI-Specification/issues/1635/labels{/name}","comments_url":"https://api.github.com/repos/OAI/OpenAPI-Specification/issues/1635/comments","events_url":"https://api.github.com/repos/OAI/OpenAPI-Specification/issues/1635/events","html_url":"https://github.com/OAI/OpenAPI-Specification/issues/1635","id":342024767,"node_id":"MDU6SXNzdWUzNDIwMjQ3Njc=","number":1635,"title":"Proposal: support fragment identifier in path object","user":{"login":"link89","id":3314130,"node_id":"MDQ6VXNlcjMzMTQxMzA=","avatar_url":"https://avatars2.githubusercontent.com/u/3314130?v=4","gravatar_id":"","url":"https://api.github.com/users/link89","html_url":"https://github.com/link89","followers_url":"https://api.github.com/users/link89/followers","following_url":"https://api.github.com/users/link89/following{/other_user}","gists_url":"https://api.github.com/users/link89/gists{/gist_id}","starred_url":"https://api.github.com/users/link89/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/link89/subscriptions","organizations_url":"https://api.github.com/users/link89/orgs","repos_url":"https://api.github.com/users/link89/repos","events_url":"https://api.github.com/users/link89/events{/privacy}","received_events_url":"https://api.github.com/users/link89/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2018-07-17T18:01:46Z","updated_at":"2019-08-22T12:10:28Z","closed_at":null,"author_association":"NONE","body":"OpenAPI spec is design for modeling REST APIs, but in real world we may find some APIs are mixture of restful style and RPC style.\r\nThose RPC APIs may share same URI, but their schema or content of their request body or query parameters are different.\r\nIt's common to meet this problem when you try to model APIs that have been in your company for a long time.\r\nAs far as I know OpenAPI spec cannot model those kind of APIs properly because the combination of verb+path uniquely identify an operation.\r\nI found that there are other people have similar problem with us:\r\n\r\nhttps://github.com/swagger-api/swagger-core/issues/935\r\nhttps://github.com/swagger-api/swagger-editor/issues/854\r\n\r\nBut we found that this problem can be solved by simply adding [fragment identifier](https://en.wikipedia.org/wiki/Fragment_identifier) in path objects.\r\n\r\nHere is the example. There are some RPC style APIs sharing same path /api/team/{team_id} and verb \"POST\". Their request body may look like\r\n```javascript\r\n// Add members\r\n{\"operation\": \"add members\", \"data\": {\"members\": [1, 2]}}\r\n\r\n// Remove members\r\n{\"operation\": \"remove members\", \"data\": {\"members\": [3, 4]}}\r\n```\r\n(I know they are bad designed, but they do exist and we have to model them.) By default, tools like Swagger-UI/Editor or swagger code generators cannot handle this case properly because their path and verb are same. In order to model those APIs, we add a fragment identifier after path for each RPC APIs\r\n```yaml\r\n/api/team/{team_id}#AddMember:\r\n    post:\r\n        ...\r\n/api/team/{team_id}#RemoveMember:\r\n    post:\r\n        ...\r\n```\r\nAnd Swagger-UI/Editor will treat them as different paths after we add this fragment, so that we can now model these RPC APIs like other restful ones in swagger editor.\r\nBecause standard HTTP clients (browsers, ajax, urllib/requests in python, etc) will automatically omit fragment in url when making reqeusts, even we add fragment in path object, tools like Swagger-UI/Editor or clients created from swagger code genenerators can still work properly.\r\nAnd that's all we need to do.\r\n\r\nAccoding to wikiepdia\r\n```\r\nIn computer hypertext, a fragment identifier is a short string of characters that refers to a resource that is subordinate to another, primary resource. The primary resource is identified by a Uniform Resource Identifier (URI), and the fragment identifier points to the subordinate resources\r\n```\r\n\r\nI think it is reasonable to use fragment identifier this way in OpenAPI. \r\nAnd I hope this proposal can become parts of OpenAPI spec to help other people who have similar problems.\r\n\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/OAI/OpenAPI-Specification/issues/comments/523878033","html_url":"https://github.com/OAI/OpenAPI-Specification/issues/1635#issuecomment-523878033","issue_url":"https://api.github.com/repos/OAI/OpenAPI-Specification/issues/1635","id":523878033,"node_id":"MDEyOklzc3VlQ29tbWVudDUyMzg3ODAzMw==","user":{"login":"ashish25cca","id":54351144,"node_id":"MDQ6VXNlcjU0MzUxMTQ0","avatar_url":"https://avatars2.githubusercontent.com/u/54351144?v=4","gravatar_id":"","url":"https://api.github.com/users/ashish25cca","html_url":"https://github.com/ashish25cca","followers_url":"https://api.github.com/users/ashish25cca/followers","following_url":"https://api.github.com/users/ashish25cca/following{/other_user}","gists_url":"https://api.github.com/users/ashish25cca/gists{/gist_id}","starred_url":"https://api.github.com/users/ashish25cca/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ashish25cca/subscriptions","organizations_url":"https://api.github.com/users/ashish25cca/orgs","repos_url":"https://api.github.com/users/ashish25cca/repos","events_url":"https://api.github.com/users/ashish25cca/events{/privacy}","received_events_url":"https://api.github.com/users/ashish25cca/received_events","type":"User","site_admin":false},"created_at":"2019-08-22T12:10:28Z","updated_at":"2019-08-22T12:10:28Z","author_association":"NONE","body":"@link89, hey, I'm seriously missing something. So, this is I've done:\r\n\r\n1). Downloaded swagger editor from this link:\r\nhttps://github.com/swagger-api/swagger-editor\r\n\r\n2). Now, since node_modules are not present into this by default, I went to the director location through terminal and run \r\n<code>\r\nnpm run dev\r\n</code>\r\n\r\n3. So, by now I have node_modules folder in my project, I changed code in node_modules/swagger-client/dist/index.js at line number 740 \r\n\r\n<code>\r\n\r\nvar finalStr = joinSearch(newStr, encodeFormOrQuery(query));\r\nreq.url = baseUrl.split('#')[0] + finalStr\r\ndelete req.query;\r\n} return req;\r\n\r\n</code>\r\n\r\n4). When I run it through local host, still fragment are not removed: \r\n\r\n<img width=\"1258\" alt=\"Screen Shot 2019-08-21 at 1 32 54 PM\" src=\"https://user-images.githubusercontent.com/54351144/63513425-cc058b80-c503-11e9-9b68-b4e0b40aea0a.png\">\r\n\r\nPlease suggest what I'm missing here.\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n"}}
{"actor":{"display_login":"ashish25cca"}}