{"id":21237862,"url":"https://github.com/marcosvidolin/ditiow","last_synced_at":"2025-07-10T18:32:29.949Z","repository":{"id":52547136,"uuid":"229589609","full_name":"marcosvidolin/ditiow","owner":"marcosvidolin","description":"🚀 Ditiow is a simple aspect library designed to help you safely expose features of your Spring REST API without having to expose data from the persistence or business layer of your application.","archived":false,"fork":false,"pushed_at":"2021-05-15T20:04:23.000Z","size":279,"stargazers_count":4,"open_issues_count":9,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T16:12:08.243Z","etag":null,"topics":["api","data-transfer-object","dto","microservices","resource","rest","rest-api","spring","spring-boot","webservice"],"latest_commit_sha":null,"homepage":"","language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/marcosvidolin.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}},"created_at":"2019-12-22T15:33:02.000Z","updated_at":"2023-06-10T10:24:11.000Z","dependencies_parsed_at":"2022-08-28T00:12:28.779Z","dependency_job_id":null,"html_url":"https://github.com/marcosvidolin/ditiow","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/marcosvidolin/ditiow","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosvidolin%2Fditiow","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosvidolin%2Fditiow/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosvidolin%2Fditiow/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosvidolin%2Fditiow/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/marcosvidolin","download_url":"https://codeload.github.com/marcosvidolin/ditiow/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/marcosvidolin%2Fditiow/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264631213,"owners_count":23640941,"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":["api","data-transfer-object","dto","microservices","resource","rest","rest-api","spring","spring-boot","webservice"],"created_at":"2024-11-21T00:21:37.564Z","updated_at":"2025-07-10T18:32:29.610Z","avatar_url":"https://github.com/marcosvidolin.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"![ditiow](docs/assets/logo.png)\n\n[ ![Download](https://api.bintray.com/packages/marcosvidolin/maven/ditiow/images/download.svg?version=1.2.0) ](https://bintray.com/marcosvidolin/maven/ditiow/1.2.0/link) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/5f79c15a8aa44706afcf49261c1a6ef1)](https://www.codacy.com/manual/marcosvidolin/ditiow?utm_source=github.com\u0026amp;utm_medium=referral\u0026amp;utm_content=marcosvidolin/ditiow\u0026amp;utm_campaign=Badge_Grade) ![Build](https://github.com/marcosvidolin/ditiow/workflows/Java%20CI%20with%20Gradle/badge.svg?branch=master)\n\nDitiow is an aspect library designed to help you safely expose features of your Spring REST API without having to expose data from the persistence or business layer of your application.\n\n## Setup\n\n1. Ditiow is release by publishing in to the JCenter. So add the \"jcenter\" in your dependency management.\n\n    - Gradle\n    \n    ```groovy      \n\trepositories {\n\t    jcenter()\n\t}\n    ```\n    \n    - Maven\n    \n    ```xml\n\t\u003crepositories\u003e\n\t\t\u003crepository\u003e\n\t\t\t\u003cid\u003ejcenter\u003c/id\u003e\n\t\t\t\u003cname\u003ejcenter\u003c/name\u003e\n\t\t\t\u003curl\u003ehttps://jcenter.bintray.com\u003c/url\u003e\n\t\t\u003c/repository\u003e\n\t\u003c/repositories\u003e\n    ```\n\n2. Declaring the dependency\n\n    - Gradle\n    \n    ```groovy\n    compile 'com.vidolima:ditiow:1.2.0'\n    ```\n   \n   - Maven\n   \n   ```xml\n   \u003cdependency\u003e\n   \t\u003cgroupId\u003ecom.vidolima\u003c/groupId\u003e\n   \t\u003cartifactId\u003editiow\u003c/artifactId\u003e\n   \t\u003cversion\u003e1.2.0\u003c/version\u003e\n   \t\u003ctype\u003epom\u003c/type\u003e\n   \u003c/dependency\u003e\n   ```\n   \n3. Declare DitiowAspect as a bean. Add aspect bean in one of the @Configuration classes\n\n    ```java\n    @Configuration\n    public class DitiowConfig {\n    \n        @Bean\n        public DitiowAspect ditiow() {\n            return new DitiowAspect();\n        }\n\n    }\n    ```\n\n## How to use\n\nDomain class with all fields. **Nothing needs to be done at this point**.\n\n```java\npublic class Post {\n\n  private Long code;\n  private UUID uuid;\n  private User author;\n  private String content;\n  private Date publishedAt;\n  private Collection\u003cComment\u003e comments;\n  // ...\n}\n```\n\n### Returning a resource from the controller\n\n- Here we specify the resource or how our Post object will be exposed by the API.\nWe do this by extending the AbstractResource class and informing the domain class (Post) as type. \nNote that the name of the attributes are the same as Post.\n\n    *But I don't want to expose some attributes like database id and comments, for example.*\n\n    ```java\n    public class PostGetResource extends AbstractResource\u003cPost\u003e {\n      private UUID uuid;\n      private User author;\n      private String content;\n      private Date publishedAt;\n      // ...\n    }\n    ```\n\n- Enable conversion by adding @ResponseResource annotation on controller class with the \"PostGetResource\" as the value of the annotation.\n\n    ```java\n      @GetMapping(path = \"/posts/{uuid}\")\n      @ResponseResource(PostGetResource.class)\n      public ResponseEntity\u003c?\u003e get(@PathVariable UUID uuid) {\n        Post post = this.postService.findPostByUuid(uuid);\n        return ResponseEntity.ok(post);\n      }\n    ```\n\n     Here the magic happens. The response will be converted to a PostGetResource object that is inserted into the body of the ResponseEntity object. \n\n### Ignore the properties of a Resource at response time\n\n- In this example the values of `author` and `publichedAt` fields will not be returned in the response\n\n    *Whenever a primitive field is ignored, its original value will be omitted and the corresponding default value will be returned.*\n\n```java\n  @GetMapping(path = \"/posts/{uuid}\")\n  @ResponseResource(PostGetResource.class, ignoreProperties = {\"author\", \"publishedAt\"})\n  public ResponseEntity\u003c?\u003e get(@PathVariable UUID uuid) {\n    Post post = this.postService.findPostByUuid(uuid);\n    return ResponseEntity.ok(post);\n  }\n```\n    \n### Retrieving a resource as a parameter\n\n```java\npublic class PostCreateResource extends AbstractResource\u003cPost\u003e {\n  private UUID uuid;\n  @NotEmpty\n  @Length(min = 50, max = 300)\n  private String content;\n  // ...\n}\n```\n\n```java\n  @PostMapping(path = \"/posts\")\n  @ResponseResource(PostGetResource.class)\n  public ResponseEntity\u003c?\u003e create(@Valid @RequestBody PostCreateResource resource) {\n    Post post = resource.toDomain(); // converts the resource into a Post\n    post.setAuthor(this.currentUserUtil.getUser());\n    return ResponseEntity.ok(this.postService.create(post));\n  }\n```\n\n## Contributors\n\n[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/images/0)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/links/0)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/images/1)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/links/1)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/images/2)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/links/2)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/images/3)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/links/3)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/images/4)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/links/4)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/images/5)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/links/5)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/images/6)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/links/6)[![](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/images/7)](https://sourcerer.io/fame/marcosvidolin/marcosvidolin/ditiow/links/7)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcosvidolin%2Fditiow","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarcosvidolin%2Fditiow","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarcosvidolin%2Fditiow/lists"}