Skip to content
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

Ability to generate docs to path other than /jsondoc/ #209

Open
DougBraidwood opened this issue Sep 30, 2016 · 4 comments
Open

Ability to generate docs to path other than /jsondoc/ #209

DougBraidwood opened this issue Sep 30, 2016 · 4 comments

Comments

@DougBraidwood
Copy link

JSONDoc is serving up the documentation at the endpoint /jsondoc/jsondoc-ui.html

I would like to map it somewhere else e.g. /lowerlevel/jsondoc/jsondoc-ui.html

And when I look at the code in GitHub I think this is coming from line 26 of JSONDocController

public final static String JSONDOC_DEFAULT_PATH = "/jsondoc";

It would be great if we could have a way to override the JSONDOC_DEFAULT_PATH

@ST-DDT
Copy link

ST-DDT commented Feb 28, 2017

AFAICT this is a limitation of spring.
Since it is used in the annotation you cannot overwrite it anyway.
However you can overwrite it if you subclass the controller.

@joffrey-bion
Copy link

According to this stackoverflow answer, it seems that it could be configurable via properties.

@ST-DDT
Copy link

ST-DDT commented Sep 26, 2017

@joffrey-bion : It could be made configurable, but currently it is not.

This can be changed by doing the following:

@Controller
public class CustomJSONDocController extends JSONDocController {

	public final static String JSONDOC_CUSTOM_PATH = "/apidoc"; // <-- Your path here

	public CustomJSONDocController(String version, String basePath, List<String> packages) {
		super(version, basePath, packages);
	}

	@Override
	@RequestMapping(value = JSONDOC_CUSTOM_PATH, method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
	public @ResponseBody JSONDoc getApi() {
		return super.getAPI();
	}

}

Just make sure you don't have the other class on your component scanning path / declared as bean.

@joffrey-bion
Copy link

joffrey-bion commented Sep 26, 2017

@ST-DDT Yes, I meant it could be made configurable. My comment's goal was to provide an idea as to how to implement this feature.

That being said, I'm not sure it would be worth adding configurability in this respect. I feel like the springmvc module provides a default controller for developers that don't want to spend time creating their own controller.
If someone seeks more flexibility, there is always the possibility to create your own controller to call JsonDoc generation and return the output JSON.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants