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

full class name as schema name, #108

Open
perluqing opened this issue Sep 24, 2020 · 0 comments
Open

full class name as schema name, #108

perluqing opened this issue Sep 24, 2020 · 0 comments

Comments

@perluqing
Copy link

perluqing commented Sep 24, 2020

version 3.0.0
How can I use full class name as schema name,
swagger-api/swagger-core#2861 this was for swagger`s way,
but in springfox,I found the ModelConverter was never called.

    ModelConverters.getInstance().addConverter(new ModelResolver(Json.mapper(),new TypeNameResolver(){
        @Override
        protected String nameForClass(Class<?> cls, Set<Options> options) {

            String className = cls.getName().startsWith("java.") ? cls.getSimpleName() : cls.getName();
            if (options.contains(Options.SKIP_API_MODEL)) {
                return className;
            }
            final io.swagger.v3.oas.annotations.media.Schema model = cls.getAnnotation(io.swagger.v3.oas.annotations.media.Schema.class);
            final String modelName = model == null ? null : StringUtils.trimToNull(model.name());
            log.info(modelName);
            return modelName == null ? className : modelName;
        }
    }));
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

1 participant