springfox.documentation.spi.schema.contexts.ModelContext Java Examples
The following examples show how to use
springfox.documentation.spi.schema.contexts.ModelContext.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ApiMethodReader.java From swagger-more with Apache License 2.0 | 6 votes |
private void readReturnDescription(OperationContext context, ApiMethod apiMethod) { ResolvedType returnType = context.alternateFor(context.getReturnType()); String message = StringUtils.isEmpty(apiMethod.returnDescription()) ? "成功" : apiMethod.returnDescription(); ModelReference modelRef = null; if (!isVoid(returnType)) { ModelContext modelContext = ModelContext.returnValue( context.getGroupName(), returnType, context.getDocumentationType(), context.getAlternateTypeProvider(), context.getGenericsNamingStrategy(), context.getIgnorableParameterTypes()); modelRef = modelRefFactory(modelContext, typeNameExtractor).apply(returnType); } ResponseMessage built = new ResponseMessageBuilder() .code(HttpStatus.OK.value()) .message(message) .responseModel(modelRef) .build(); context.operationBuilder().responseMessages(newHashSet(built)); }
Example #2
Source File: SwaggerConfiguration.java From ci-droid with Apache License 2.0 | 6 votes |
@Override public void apply(ModelContext modelContext) { Class<?> modelClass = forClass(modelContext); modelContext.getType(); if(modelClass.equals(AbstractGitHubInteraction.class)){ abstractGitHubInteractionSpecificConfig(modelContext); } else if(modelClass.equals(ActionToReplicate.class)){ actionToReplicateSpecificConfig(modelContext); } else if(modelClass.equals(ResourceToUpdate.class)){ resourcesToUpdateSpecificConfig(modelContext); } }
Example #3
Source File: ModelCache.java From Resource with GNU General Public License v3.0 | 6 votes |
public Function<ResolvedType, ? extends ModelReference> getFactory() { if (factory == null) { List<DefaultTypeNameProvider> providers = new ArrayList(); providers.add(new DefaultTypeNameProvider()); PluginRegistry<TypeNameProviderPlugin, DocumentationType> modelNameRegistry = OrderAwarePluginRegistry.create(providers); TypeNameExtractor typeNameExtractor = new TypeNameExtractor( typeResolver, modelNameRegistry, new JacksonEnumTypeDeterminer()); ModelContext modelContext = inputParam( context.getGroupName(), String.class, context.getDocumentationType(), context.getAlternateTypeProvider(), context.getGenericsNamingStrategy(), context.getIgnorableParameterTypes()); factory = ResolvedTypes.modelRefFactory(modelContext, typeNameExtractor); } return factory; }
Example #4
Source File: SwaggerConfiguration.java From ci-droid with Apache License 2.0 | 5 votes |
private void actionToReplicateSpecificConfig(ModelContext modelContext) { Map actionToReplicateProperties = new HashMap<String, ModelProperty>(); List<String> availableActionClassNames=availableActions.stream().map(a -> a.getClass().getCanonicalName()).collect(toList()); ModelProperty actionToReplicateClassNameProperty=new ModelPropertyBuilder().required(true) .allowEmptyValue(false) .name("fully qualified class name identifier") .description("fully qualified name of the class implementing com.societegenerale.cidroid.api.actionToReplicate.ActionToReplicate") .allowableValues(new AllowableListValues(availableActionClassNames,"string")) .example((Object)"com.societegenerale.cidroid.extensions.actionToReplicate.OverwriteStaticFileAction") .type(resolver.resolve(String.class)).build(); actionToReplicateClassNameProperty.updateModelRef(modelRefFactory(modelContext, typeNameExtractor)); actionToReplicateProperties.put("@class",actionToReplicateClassNameProperty); ModelProperty actionToReplicateAttributeProperty=new ModelPropertyBuilder().required(true) .allowEmptyValue(false) .name("example of attribute") .description("depends on the @class picked. See in GET /cidroid-actions/availableActions , which classes you can use, and what are the expected fields for each") .type(resolver.resolve(String.class)).build(); actionToReplicateAttributeProperty.updateModelRef(modelRefFactory(modelContext, typeNameExtractor)); actionToReplicateProperties.put("someActionAttribute",actionToReplicateAttributeProperty); modelContext.getBuilder() .properties(actionToReplicateProperties) .description("see the Jackson config and the subclasses of in https://github.com/societe-generale/ci-droid-internal-api/blob/master/src/main/java/com/societegenerale/cidroid/api/actionToReplicate/ActionToReplicate.java"); }
Example #5
Source File: SwaggerConfiguration.java From ci-droid with Apache License 2.0 | 5 votes |
private void abstractGitHubInteractionSpecificConfig(ModelContext modelContext) { Map abstractGitHubInteractionProperties=new HashMap<String, ModelProperty>(); ModelProperty abstractGitHubInteractionClassNameProperty=new ModelPropertyBuilder().required(true) .allowEmptyValue(false) .name("class identifier") .allowableValues(new AllowableListValues( Arrays.asList(".DirectPushGitHubInteraction",".PullRequestGitHubInteraction"),"string")) .example((Object)".DirectPushGitHubInteraction") .type(resolver.resolve(String.class)).build(); abstractGitHubInteractionClassNameProperty.updateModelRef(modelRefFactory(modelContext, typeNameExtractor)); abstractGitHubInteractionProperties.put("@c",abstractGitHubInteractionClassNameProperty); ModelProperty branchNameProperty=new ModelPropertyBuilder().required(false) .name("branch name in case of PR") .description("when @c=.PullRequestGitHubInteraction, then we need to provide the name of the branch in which we want to the PR") .example((Object)"myBranch") .type(resolver.resolve(String.class)).build(); branchNameProperty.updateModelRef(modelRefFactory(modelContext, typeNameExtractor)); abstractGitHubInteractionProperties.put("branchNameToCreate",branchNameProperty); ModelProperty prTitleProperty=new ModelPropertyBuilder().required(false) .name("title of the PR") .description("when @c=.PullRequestGitHubInteraction, then we can provide a title for the PR. If not provided, the PR title will be the same as the branch name") .example((Object)"'[XYZ-123] adding a feature'") .type(resolver.resolve(String.class)).build(); prTitleProperty.updateModelRef(modelRefFactory(modelContext, typeNameExtractor)); abstractGitHubInteractionProperties.put("pullRequestTitle",prTitleProperty); modelContext.getBuilder() .properties(abstractGitHubInteractionProperties) .description("see the Jackson config in https://github.com/societe-generale/ci-droid-internal-api/blob/master/src/main/java/com/societegenerale/cidroid/api/gitHubInteractions/AbstractGitHubInteraction.java"); }
Example #6
Source File: PageableParameterBuilderPlugin.java From spring-cloud-gray with Apache License 2.0 | 5 votes |
private Function<ResolvedType, ? extends ModelReference> createModelRefFactory(ParameterContext context) { ModelContext modelContext = inputParam( context.getGroupName(), context.resolvedMethodParameter().getParameterType(), context.getDocumentationType(), context.getAlternateTypeProvider(), context.getGenericNamingStrategy(), context.getIgnorableParameterTypes()); return ResolvedTypes.modelRefFactory(modelContext, nameExtractor); }
Example #7
Source File: SwaggerUtil.java From BlogManagePlatform with Apache License 2.0 | 5 votes |
/** * 从OperationContext转换出ModelContext * @author Frodez * @date 2019-12-15 */ public static ModelContext resolveModelContext(OperationContext context, Type type) { String group = context.getGroupName(); DocumentationType documentation = context.getDocumentationType(); AlternateTypeProvider provider = context.getAlternateTypeProvider(); GenericTypeNamingStrategy strategy = context.getGenericsNamingStrategy(); @SuppressWarnings("rawtypes") ImmutableSet<Class> types = context.getIgnorableParameterTypes(); return returnValue(group, type, documentation, provider, strategy, types); }
Example #8
Source File: PageableParameterBuilderPlugin.java From albedo with GNU Lesser General Public License v3.0 | 5 votes |
protected Function<ResolvedType, ? extends ModelReference> createModelRefFactory(ParameterContext context) { ModelContext modelContext = inputParam( context.getGroupName(), context.resolvedMethodParameter().getParameterType(), context.getDocumentationType(), context.getAlternateTypeProvider(), context.getGenericNamingStrategy(), context.getIgnorableParameterTypes()); return (Function<ResolvedType, ? extends ModelReference>) modelRefFactory(modelContext, nameExtractor); }
Example #9
Source File: ParametersReader.java From Resource with GNU General Public License v3.0 | 5 votes |
private Function<ResolvedType, ? extends ModelReference> createModelRefFactory(ParameterContext context) { ModelContext modelContext = inputParam( context.getGroupName(), context.resolvedMethodParameter().getParameterType(), context.getDocumentationType(), context.getAlternateTypeProvider(), context.getGenericNamingStrategy(), context.getIgnorableParameterTypes()); return ResolvedTypes.modelRefFactory(modelContext, nameExtractor); }
Example #10
Source File: PageableParameterBuilderPlugin.java From jhipster with Apache License 2.0 | 5 votes |
/** * <p>createModelRefFactory.</p> * * @param context a {@link springfox.documentation.spi.service.contexts.ParameterContext} object. * @return a {@link java.util.function.Function} object. */ protected Function<ResolvedType, ? extends ModelReference> createModelRefFactory(ParameterContext context) { ModelContext modelContext = inputParam( context.getGroupName(), context.resolvedMethodParameter().getParameterType(), context.getDocumentationType(), context.getAlternateTypeProvider(), context.getGenericNamingStrategy(), context.getIgnorableParameterTypes()); return modelRefFactory(modelContext, nameExtractor); }
Example #11
Source File: ModelExtendsBuilder.java From swagger-more with Apache License 2.0 | 4 votes |
@Override public void apply(ModelContext context) { Type type = context.getType(); context.getBuilder().name(type.getTypeName()).build(); }
Example #12
Source File: SwaggerConfiguration.java From ci-droid with Apache License 2.0 | 4 votes |
private void resourcesToUpdateSpecificConfig(ModelContext modelContext) { Map resourcesToUpdateProperties=new HashMap<String, ModelProperty>(); ModelProperty repoFullNameProperty=new ModelPropertyBuilder().required(true) .allowEmptyValue(false) .name("repo full name") .position(1) .example((Object)"vincent-fuchs/in-memory-testing") .type(resolver.resolve(String.class)).build(); repoFullNameProperty.updateModelRef(modelRefFactory(modelContext, typeNameExtractor)); resourcesToUpdateProperties.put("repoFullName",repoFullNameProperty); ModelProperty filePathOnRepoProperty=new ModelPropertyBuilder().required(true) .allowEmptyValue(false) .name("file path") .position(2) .example((Object)"pom.xml") .type(resolver.resolve(String.class)).build(); filePathOnRepoProperty.updateModelRef(modelRefFactory(modelContext, typeNameExtractor)); resourcesToUpdateProperties.put("filePathOnRepo",filePathOnRepoProperty); ModelProperty branchProperty=new ModelPropertyBuilder().required(true) .allowEmptyValue(false) .name("branch") .position(3) .example((Object)"master") .type(resolver.resolve(String.class)).build(); branchProperty.updateModelRef(modelRefFactory(modelContext, typeNameExtractor)); resourcesToUpdateProperties.put("branchName",branchProperty); ModelProperty placeHolderValueProperty=new ModelPropertyBuilder().required(false) .name("placeHolderValue") .position(4) .description("when using @class TemplateBasedContentAction, we use a template with a placeholder : the value to use is provided with each resource") .type(resolver.resolve(String.class)).build(); placeHolderValueProperty.updateModelRef(modelRefFactory(modelContext, typeNameExtractor)); resourcesToUpdateProperties.put("placeHolderValue",placeHolderValueProperty); modelContext.getBuilder() .properties(resourcesToUpdateProperties) .description("a list of description of resources, for which the updateAction will be performed"); }
Example #13
Source File: SwaggerConfiguration.java From ci-droid with Apache License 2.0 | 4 votes |
private Class<?> forClass(ModelContext context) { return resolver.resolve(context.getType()).getErasedType(); }
Example #14
Source File: SuccessPlugin.java From BlogManagePlatform with Apache License 2.0 | 4 votes |
private ModelReference resolveModel(OperationContext context, Success success) { ModelContext modelContext = SwaggerUtil.resolveModelContext(context, success.value()); ResolvedType type = context.alternateFor(SwaggerUtil.resolvedType(typeResolver, success)); return modelRefFactory(modelContext, typeNameExtractor).apply(type); }
Example #15
Source File: JobParameterDescriptionSerializer.java From haven-platform with Apache License 2.0 | 4 votes |
private String toString(Type type) { ModelContext modelContext = ModelContext.returnValue("com.codeabovelab.dm", type, DocumentationType.SPRING_WEB, null, new DefaultGenericTypeNamingStrategy(), null); return typeNameExtractor.typeName(modelContext); }