springfox.documentation.spi.service.contexts.DocumentationContext Java Examples
The following examples show how to use
springfox.documentation.spi.service.contexts.DocumentationContext.
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: SwaggerManualApiPlugin.java From java-starthere with MIT License | 6 votes |
@Override public List<ApiDescription> apply(DocumentationContext documentationContext) { return new ArrayList<>(Arrays.asList(new ApiDescription(null, "/login", "login", Arrays.asList(new OperationBuilder(operationNames).authorizations(new ArrayList<>()) .summary("login") .codegenMethodNameStem("userLogin") .method(HttpMethod.POST) .notes("This is the login endpoint to request an authentication token") .responseMessages(responseMessages()) .parameters(Arrays.asList(new ParameterBuilder().description("Login Parameter") .type(new TypeResolver().resolve(UserLogin.class)) .name("userLogin") .parameterType("body") .parameterAccess("access") .required(true) .modelRef(new ModelRef("UserLogin")) .build())) .build()), false))); }
Example #2
Source File: PageableParameterBuilderPluginTest.java From jhipster with Apache License 2.0 | 6 votes |
@BeforeEach public void setup() throws Exception { MockitoAnnotations.initMocks(this); Method method = this.getClass().getMethod("test", new Class<?>[]{Pageable.class, Integer.class}); resolver = new TypeResolver(); RequestHandler handler = new WebMvcRequestHandler(new HandlerMethodResolver(resolver), null, new HandlerMethod(this, method)); DocumentationContext docContext = mock(DocumentationContext.class); RequestMappingContext reqContext = new RequestMappingContext(docContext, handler); builder = spy(new OperationBuilder(null)); context = new OperationContext(builder, RequestMethod.GET, reqContext, 0); List<TypeNameProviderPlugin> plugins = new LinkedList<>(); extractor = new TypeNameExtractor(resolver, SimplePluginRegistry.create(plugins), new JacksonEnumTypeDeterminer()); plugin = new PageableParameterBuilderPlugin(extractor, resolver); }
Example #3
Source File: ApiListingJsonScanner.java From Resource with GNU General Public License v3.0 | 5 votes |
private Predicate<ApiDescription> onlySelectedApis(final DocumentationContext context) { return new Predicate<ApiDescription>() { @Override public boolean apply(ApiDescription input) { return context.getApiSelector().getPathSelector().apply(input.getPath()); } }; }
Example #4
Source File: ApiListingJsonScanner.java From Resource with GNU General Public License v3.0 | 4 votes |
public Multimap<String, ApiListing> scan(ApiListingScanningContext context) { final Multimap<String, ApiListing> apiListingMap = LinkedListMultimap.create(); int position = 0; Map<ResourceGroup, List<RequestMappingContext>> requestMappingsByResourceGroup = context.getRequestMappingsByResourceGroup(); Collection<ApiDescription> additionalListings = pluginsManager.additionalListings(context); Set<ResourceGroup> allResourceGroups = from(collectResourceGroups(additionalListings)) .append(requestMappingsByResourceGroup.keySet()) .toSet(); List<SecurityReference> securityReferences = newArrayList(); for (final ResourceGroup resourceGroup : sortedByName(allResourceGroups)) { DocumentationContext documentationContext = context.getDocumentationContext(); Set<String> produces = new LinkedHashSet<String>(documentationContext.getProduces()); Set<String> consumes = new LinkedHashSet<String>(documentationContext.getConsumes()); String host = documentationContext.getHost(); Set<String> protocols = new LinkedHashSet<String>(documentationContext.getProtocols()); Set<ApiDescription> apiDescriptions = newHashSet(); Map<String, Model> models = new LinkedHashMap<String, Model>(); List<RequestMappingContext> requestMappings = nullToEmptyList( requestMappingsByResourceGroup.get(resourceGroup)); for (RequestMappingContext each : sortedByMethods(requestMappings)) {//url Map<String, Model> knownModels = new HashMap<>(); models.putAll(apiModelReader.read(each.withKnownModels(models))); apiDescriptions.addAll(apiDescriptionReader.read(each)); } // models.putAll(ModelCache.getInstance().getKnownModels()); List<ApiDescription> additional = from(additionalListings) .filter(and( belongsTo(resourceGroup.getGroupName()), onlySelectedApis(documentationContext))) .toList(); apiDescriptions.addAll(additional); List<ApiDescription> sortedApis = from(apiDescriptions) .toSortedList(documentationContext.getApiDescriptionOrdering()); Optional<String> o = longestCommonPath(sortedApis); String resourcePath = new ResourcePathProvider(resourceGroup) .resourcePath() .or(o) .orNull(); PathProvider pathProvider = documentationContext.getPathProvider(); String basePath = pathProvider.getApplicationBasePath(); PathAdjuster adjuster = new PathMappingAdjuster(documentationContext); ApiListingBuilder apiListingBuilder = new ApiListingBuilder(context.apiDescriptionOrdering()) .apiVersion(documentationContext.getApiInfo().getVersion()) .basePath(adjuster.adjustedPath(basePath)) .resourcePath(resourcePath) .produces(produces) .consumes(consumes) .host(host) .protocols(protocols) .securityReferences(securityReferences) .apis(sortedApis) .models(models) .position(position++) .availableTags(documentationContext.getTags()); ApiListingContext apiListingContext = new ApiListingContext( context.getDocumentationType(), resourceGroup, apiListingBuilder); apiListingMap.put(resourceGroup.getGroupName(), pluginsManager.apiListing(apiListingContext)); } return apiListingMap; }
Example #5
Source File: ModelCache.java From Resource with GNU General Public License v3.0 | 4 votes |
public void setContext(DocumentationContext context) { this.context = context; }
Example #6
Source File: ModelCache.java From Resource with GNU General Public License v3.0 | 4 votes |
public DocumentationContext getContext() { return context; }