Closed MikeSafonov closed 5 years ago
Hi, before we merge #329, did you try to reuse SnippetMessages.properties via shared library? I guess resource should be possible to find anywhere on the classpath wherever it comes from. How are you going to register your translation resolver using spring boot starter?
Hello. Of course, you are right, but properties file comes with some encoding issues. For example my SnippetMessages.properties file looks like this:
authorization=\u0410\u0432\u0442\u043E\u0440\u0438\u0437\u0430\u0446\u0438\u044F
After #329 will be merged, I will be able to store my translations anywhere: source code / json, properties files / access via HTTP API / something else. And most importantly, I will be able to control the format and encoding of translations by myself.
As for the starter, I could suggest the following options :
Starter comes with already created and configured mockMvc using abstract EndpoitTest. Some code concept:
public abstract class EndpointTest {
@Autowired
protected MockMvc mockMvc;
@Autowired
protected ObjectMapper objectMapper;
@BeforeEach
void setUp(WebApplicationContext context,
RestDocumentationContextProvider restDocumentation) {
SnippetTranslationResolver translationResolver = new JsonSnippetTranslationResolver();
ConstraintDescriptionResolver constraintDescriptionResolver = new InMemoryConstraintDescriptionResolver();
this.mockMvc = MockMvcBuilders
.webAppContextSetup(context)
.alwaysDo(JacksonResultHandlers.prepareJackson(objectMapper, translationResolver, constraintDescriptionResolver ))
...
}
}
Ok sounds good! I will merge your PR. When you're ready with your part of the code and there are no fixes necessary for you on SARD side, we can release it officially with some docs.
Hi! I wrote a test starter and I have no fixes or improvements. I think you could make a release.
Hello. Any plans to make new release?
Hi, we released 2.0.6, it should be on mvn central shortly.
Thanks!
I guess this can be closed.
Problem: I want to provide same custom snippet translation to several applications. I need to copy paste SnippetMessages.properties with same translation at every source code.
To solve this problem i want to create a starter with default spring-restdocs/spring-auto-restdocs configuration and custom translation. Unfortunately, I can’t control the behavior of the SnippetTranslationResolver.
Solution: