-
-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ArchTest:servicesAndRepositoriesShouldNotDependOnWebLayer should be deleted #10552
Comments
I will check what do do about it. The implementation of the delegate might be a service, but from an architectural point of view they belong to the web layer imho, so I guess the layer definition/slicing in the test doesn't take that into account. |
When you say the service should go into web layer, then looking at the JHipster created the package below. Do you imply that not all @service should go to that package? /**
|
Do you have an example? Where did you put your delegate implementation? I think it depends on your desired architecure. I would put the implementation of the delegate under package com.mycompany.myapp.web.rest;
import com.mycompany.myapp.web.api.PetsApiDelegate;
import org.springframework.stereotype.Component;
@Component
public class PetsApiDelegateImpl implements PetsApiDelegate {
} |
hello i think the docs in https://www.jhipster.tech/doing-api-first-development/ |
@fabioportieri (Just stumbled over this, so I realize this is very old 😉) That sounds strange, because if you did the refactoring suggested, then your OpenAPI implementations would reside within I actually think the complaint is correct, the OpenAPI generated types are parts of the web layer. Generated interfaces should be implemented in the web layer, because the services should be pure business logic and independent of the REST spec / generated classes. In the end these interfaces also define the web DTO types, no? I worked on an application not long ago that did it exactly like that. Implemented the delegates in the web layer and used services from there. IMHO that makes sense for a layered architecture. |
The arch test tests that Services and Repo's don't have web imports.
That is a problem cause with openapi (a jhipster supported tool) you get a delegate which resides in the web package. You use that delegate in a service. This causes test servicesAndRepositoriesShouldNotDependOnWebLayer to fail.
From an example Delegate:
/**
*/
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.SpringCodegen", date = "2019-10-02T16:50:02.286+02:00[Africa/Johannesburg]")
public interface ModelApiDelegate {
}
As you can see the architect of that project thought again that it be right to use this interface in a service .ie "Implement this interface with a {@link org.springframework.stereotype.Service} annotated class."
The jhipster architect thought differently.
How now?
The text was updated successfully, but these errors were encountered: