{"id":26821616,"url":"https://github.com/atkawa7/httpsnippet","last_synced_at":"2025-04-24T06:06:29.283Z","repository":{"id":34373536,"uuid":"173534034","full_name":"atkawa7/httpsnippet","owner":"atkawa7","description":"An HTTP Request snippet generator for Springfox","archived":false,"fork":false,"pushed_at":"2025-01-12T07:27:09.000Z","size":2776,"stargazers_count":20,"open_issues_count":35,"forks_count":5,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-24T06:06:24.583Z","etag":null,"topics":["har","redoc","snippet-generator","springfox","swagger"],"latest_commit_sha":null,"homepage":"https://atkawa7.github.io/httpsnippet","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atkawa7.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-03T05:17:59.000Z","updated_at":"2025-01-12T07:26:57.000Z","dependencies_parsed_at":"2025-04-06T03:00:53.240Z","dependency_job_id":null,"html_url":"https://github.com/atkawa7/httpsnippet","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atkawa7%2Fhttpsnippet","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atkawa7%2Fhttpsnippet/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atkawa7%2Fhttpsnippet/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atkawa7%2Fhttpsnippet/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atkawa7","download_url":"https://codeload.github.com/atkawa7/httpsnippet/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250573353,"owners_count":21452350,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["har","redoc","snippet-generator","springfox","swagger"],"created_at":"2025-03-30T07:31:32.000Z","updated_at":"2025-04-24T06:06:29.260Z","avatar_url":"https://github.com/atkawa7.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HTTP Snippet\n\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n![Coveralls github](https://img.shields.io/coveralls/github/atkawa7/httpsnippet.svg?label=jacoco)\n![Codecov](https://img.shields.io/codecov/c/github/atkawa7/httpsnippet.svg?label=cobertura)\n![GitHub issues](https://img.shields.io/github/issues/atkawa7/httpsnippet.svg)\n![Travis (.org)](https://img.shields.io/travis/atkawa7/httpsnippet.svg?label=travis)\n\u003e HTTP Snippet port for java. See [the original node port](https://github.com/Kong/httpsnippet). Supports *many* languages \u0026 tools including: `cURL`, `HTTPie`, `Javascript`, `Node`, `C`, `Java`, `PHP`, `Objective-C`, `Swift`, `Python`, `Ruby`, `C#`, `Go`, `OCaml` and more!\n\n\n***The motivation behind porting this is using it for generating snippets in swagger and redocs.\nThe project is still in development phase***. \n\n- [x] Documentation\n- [x] Tests\n- [ ] Releasing to maven\n\n##  Usage\nEnable maven snapshots in `~/.m2/settings.xml`\n```xml\n\u003cprofiles\u003e\n  \u003cprofile\u003e\n     \u003cid\u003eallow-snapshots\u003c/id\u003e\n        \u003cactivation\u003e\u003cactiveByDefault\u003etrue\u003c/activeByDefault\u003e\u003c/activation\u003e\n     \u003crepositories\u003e\n       \u003crepository\u003e\n         \u003cid\u003esnapshots-repo\u003c/id\u003e\n         \u003curl\u003ehttps://oss.sonatype.org/content/repositories/snapshots\u003c/url\u003e\n         \u003creleases\u003e\u003cenabled\u003efalse\u003c/enabled\u003e\u003c/releases\u003e\n         \u003csnapshots\u003e\u003cenabled\u003etrue\u003c/enabled\u003e\u003c/snapshots\u003e\n       \u003c/repository\u003e\n     \u003c/repositories\u003e\n   \u003c/profile\u003e\n\u003c/profiles\u003e\n```\n Then add this `dependency` to  `pom.xml`\n\n```xml\n\u003cdependency\u003e\n     \u003cgroupId\u003eio.github.atkawa7\u003c/groupId\u003e\n     \u003cartifactId\u003ehttpsnippet\u003c/artifactId\u003e\n     \u003cversion\u003e0.0.1-SNAPSHOT\u003c/version\u003e\n\u003c/dependency\u003e\n```\n\nHere is the code for generating snippet\n\n```java\npublic class Main {\n     public static void main(String[] args) throws Exception {\n         List\u003cHarHeader\u003e headers = new ArrayList\u003c\u003e();\n         List\u003cHarQueryString\u003e queryStrings = new ArrayList\u003c\u003e();\n \n         User user = new User();\n         Faker faker = new Faker();\n         user.setFirstName(faker.name().firstName());\n         user.setLastName(faker.name().lastName());\n \n \n         HarPostData harPostData =\n                 new HarPostDataBuilder()\n                         .withMimeType(MediaType.APPLICATION_JSON)\n                         .withText(ObjectUtils.writeValueAsString(user)).build();\n \n         HarRequest harRequest =\n                 new HarRequestBuilder()\n                         .withMethod(HttpMethod.GET.toString())\n                         .withUrl(\"http://localhost:5000/users\")\n                         .withHeaders(headers)\n                         .withQueryString(queryStrings)\n                         .withHttpVersion(HttpVersion.HTTP_1_1.toString())\n                         .withPostData(harPostData)\n                         .build();\n \n         //Using default client\n         HttpSnippet httpSnippet = new HttpSnippetCodeGenerator().snippet(harRequest, Language.JAVA);\n         System.out.println(httpSnippet.getCode());\n \n         //Or directly using\n         String code   = new OkHttp().code(harRequest);\n         System.out.println(code);\n \n     }\n \n     @Data\n     static class User {\n         private String firstName;\n         private String lastName;\n     }\n }\n\n```\n\nThe result \n\n```java\nHttpResponse\u003cString\u003e response = Unirest.get(\"http://localhost:5000/users\")\n  .body(\"{\\\"firstName\\\":\\\"Burton\\\",\\\"lastName\\\":\\\"Greenholt\\\"}\")\n  .asString();\n```\n\n## Running the demo application\n\n```sh\nmvn clean install\njava -jar httpsnippet-demo/target/httpsnippet-demo-0.0.1-SNAPSHOT.jar\n```\n\nAfter running the demo here are the results\n\n![Alt text](images/Redoc.png?raw=true \"Redoc\")\n\n![Alt text](images/Swagger-UI.png?raw=true \"Swagger UI\")\n\n\n\n## License\n\n[Apache 2.0](LICENSE) \u0026copy; [atkawa7](https://github.com/atkawa7/httpsnippet)\n\n[license-url]: https://github.com/atkawa7/httpsnippet/blob/master/LICENSE\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatkawa7%2Fhttpsnippet","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatkawa7%2Fhttpsnippet","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatkawa7%2Fhttpsnippet/lists"}