@Test(description = "Callbacks") public void testGetCallbacks() { Reader reader = new Reader(new OpenAPI()); Method[] methods = SimpleCallbackResource.class.getMethods(); Operation callbackOperation = reader.parseMethod(methods[0], null, null); assertNotNull(callbackOperation); Map<String, Callback> callbacks = callbackOperation.getCallbacks(); assertNotNull(callbacks); Callback callback = callbacks.get(CALLBACK_SUBSCRIPTION_ID); assertNotNull(callback); PathItem pathItem = callback.get(CALLBACK_URL); assertNotNull(pathItem); Operation postOperation = pathItem.getPost(); assertNotNull(postOperation); assertEquals(CALLBACK_POST_OPERATION_DESCRIPTION, postOperation.getDescription()); Operation getOperation = pathItem.getGet(); assertNotNull(getOperation); assertEquals(CALLBACK_GET_OPERATION_DESCRIPTION, getOperation.getDescription()); Operation putOperation = pathItem.getPut(); assertNotNull(putOperation); assertEquals(CALLBACK_POST_OPERATION_DESCRIPTION, putOperation.getDescription()); }
private Map<String, Callback> getCallbacks( io.swagger.v3.oas.annotations.callbacks.Callback apiCallback, Produces methodProduces, Produces classProduces, Consumes methodConsumes, Consumes classConsumes, JsonView jsonViewAnnotation) { Map<String, Callback> callbackMap = new HashMap<>(); if (apiCallback == null) { return callbackMap; } Callback callbackObject = new Callback(); if (StringUtils.isNotBlank(apiCallback.ref())) { callbackObject.set$ref(apiCallback.ref()); callbackMap.put(apiCallback.name(), callbackObject); return callbackMap; } PathItem pathItemObject = new PathItem(); for (io.swagger.v3.oas.annotations.Operation callbackOperation : apiCallback.operation()) { Operation callbackNewOperation = new Operation(); setOperationObjectFromApiOperationAnnotation( callbackNewOperation, callbackOperation, methodProduces, classProduces, methodConsumes, classConsumes, jsonViewAnnotation); setPathItemOperation(pathItemObject, callbackOperation.method(), callbackNewOperation); } callbackObject.addPathItem(apiCallback.callbackUrlExpression(), pathItemObject); callbackMap.put(apiCallback.name(), callbackObject); return callbackMap; }
Reader implements OpenApiReader { private Map<String, Callback> getCallbacks( io.swagger.v3.oas.annotations.callbacks.Callback apiCallback, Produces methodProduces, Produces classProduces, Consumes methodConsumes, Consumes classConsumes, JsonView jsonViewAnnotation) { Map<String, Callback> callbackMap = new HashMap<>(); if (apiCallback == null) { return callbackMap; } Callback callbackObject = new Callback(); if (StringUtils.isNotBlank(apiCallback.ref())) { callbackObject.set$ref(apiCallback.ref()); callbackMap.put(apiCallback.name(), callbackObject); return callbackMap; } PathItem pathItemObject = new PathItem(); for (io.swagger.v3.oas.annotations.Operation callbackOperation : apiCallback.operation()) { Operation callbackNewOperation = new Operation(); setOperationObjectFromApiOperationAnnotation( callbackNewOperation, callbackOperation, methodProduces, classProduces, methodConsumes, classConsumes, jsonViewAnnotation); setPathItemOperation(pathItemObject, callbackOperation.method(), callbackNewOperation); } callbackObject.addPathItem(apiCallback.callbackUrlExpression(), pathItemObject); callbackMap.put(apiCallback.name(), callbackObject); return callbackMap; } }
Reader implements OpenApiReader { private Map<String, Callback> getCallbacks( io.swagger.v3.oas.annotations.callbacks.Callback apiCallback, Produces methodProduces, Produces classProduces, Consumes methodConsumes, Consumes classConsumes, JsonView jsonViewAnnotation) { Map<String, Callback> callbackMap = new HashMap<>(); if (apiCallback == null) { return callbackMap; } Callback callbackObject = new Callback(); if (StringUtils.isNotBlank(apiCallback.ref())) { callbackObject.set$ref(apiCallback.ref()); callbackMap.put(apiCallback.name(), callbackObject); return callbackMap; } PathItem pathItemObject = new PathItem(); for (io.swagger.v3.oas.annotations.Operation callbackOperation : apiCallback.operation()) { Operation callbackNewOperation = new Operation(); setOperationObjectFromApiOperationAnnotation( callbackNewOperation, callbackOperation, methodProduces, classProduces, methodConsumes, classConsumes, jsonViewAnnotation); setPathItemOperation(pathItemObject, callbackOperation.method(), callbackNewOperation); } callbackObject.addPathItem(apiCallback.callbackUrlExpression(), pathItemObject); callbackMap.put(apiCallback.name(), callbackObject); return callbackMap; } Reader();  Reader(OpenAPI openAPI);  Reader(OpenAPIConfiguration openApiConfiguration); }
Reader implements OpenApiReader { private Map<String, Callback> getCallbacks( io.swagger.v3.oas.annotations.callbacks.Callback apiCallback, Produces methodProduces, Produces classProduces, Consumes methodConsumes, Consumes classConsumes, JsonView jsonViewAnnotation) { Map<String, Callback> callbackMap = new HashMap<>(); if (apiCallback == null) { return callbackMap; } Callback callbackObject = new Callback(); if (StringUtils.isNotBlank(apiCallback.ref())) { callbackObject.set$ref(apiCallback.ref()); callbackMap.put(apiCallback.name(), callbackObject); return callbackMap; } PathItem pathItemObject = new PathItem(); for (io.swagger.v3.oas.annotations.Operation callbackOperation : apiCallback.operation()) { Operation callbackNewOperation = new Operation(); setOperationObjectFromApiOperationAnnotation( callbackNewOperation, callbackOperation, methodProduces, classProduces, methodConsumes, classConsumes, jsonViewAnnotation); setPathItemOperation(pathItemObject, callbackOperation.method(), callbackNewOperation); } callbackObject.addPathItem(apiCallback.callbackUrlExpression(), pathItemObject); callbackMap.put(apiCallback.name(), callbackObject); return callbackMap; } Reader();  Reader(OpenAPI openAPI);  Reader(OpenAPIConfiguration openApiConfiguration); OpenAPI getOpenAPI(); OpenAPI read(Class<?> cls); OpenAPI read(Set<Class<?>> classes); @Override void setConfiguration(OpenAPIConfiguration openApiConfiguration); @Override OpenAPI read(Set<Class<?>> classes, Map<String, Object> resources); OpenAPI read(Class<?> cls,
                        String parentPath,
                        String parentMethod,
                        boolean isSubresource,
                        RequestBody parentRequestBody,
                        ApiResponses parentResponses,
                        Set<String> parentTags,
                        List<Parameter> parentParameters,
                        Set<Class<?>> scannedResources); Operation parseMethod(
            Method method,
            List<Parameter> globalParameters,
            JsonView jsonViewAnnotation); Operation parseMethod(
            Method method,
            List<Parameter> globalParameters,
            Produces methodProduces,
            Produces classProduces,
            Consumes methodConsumes,
            Consumes classConsumes,
            List<SecurityRequirement> classSecurityRequirements,
            Optional<io.swagger.v3.oas.models.ExternalDocumentation> classExternalDocs,
            Set<String> classTags,
            List<io.swagger.v3.oas.models.servers.Server> classServers,
            boolean isSubresource,
            RequestBody parentRequestBody,
            ApiResponses parentResponses,
            JsonView jsonViewAnnotation,
            io.swagger.v3.oas.annotations.responses.ApiResponse[] classResponses); Operation parseMethod(
            Method method,
            List<Parameter> globalParameters,
            Produces methodProduces,
            Produces classProduces,
            Consumes methodConsumes,
            Consumes classConsumes,
            List<SecurityRequirement> classSecurityRequirements,
            Optional<io.swagger.v3.oas.models.ExternalDocumentation> classExternalDocs,
            Set<String> classTags,
            List<io.swagger.v3.oas.models.servers.Server> classServers,
            boolean isSubresource,
            RequestBody parentRequestBody,
            ApiResponses parentResponses,
            JsonView jsonViewAnnotation,
            io.swagger.v3.oas.annotations.responses.ApiResponse[] classResponses,
            AnnotatedMethod annotatedMethod); void setApplication(Application application); }
Reader implements OpenApiReader { private Map<String, Callback> getCallbacks( io.swagger.v3.oas.annotations.callbacks.Callback apiCallback, Produces methodProduces, Produces classProduces, Consumes methodConsumes, Consumes classConsumes, JsonView jsonViewAnnotation) { Map<String, Callback> callbackMap = new HashMap<>(); if (apiCallback == null) { return callbackMap; } Callback callbackObject = new Callback(); if (StringUtils.isNotBlank(apiCallback.ref())) { callbackObject.set$ref(apiCallback.ref()); callbackMap.put(apiCallback.name(), callbackObject); return callbackMap; } PathItem pathItemObject = new PathItem(); for (io.swagger.v3.oas.annotations.Operation callbackOperation : apiCallback.operation()) { Operation callbackNewOperation = new Operation(); setOperationObjectFromApiOperationAnnotation( callbackNewOperation, callbackOperation, methodProduces, classProduces, methodConsumes, classConsumes, jsonViewAnnotation); setPathItemOperation(pathItemObject, callbackOperation.method(), callbackNewOperation); } callbackObject.addPathItem(apiCallback.callbackUrlExpression(), pathItemObject); callbackMap.put(apiCallback.name(), callbackObject); return callbackMap; } Reader();  Reader(OpenAPI openAPI);  Reader(OpenAPIConfiguration openApiConfiguration); OpenAPI getOpenAPI(); OpenAPI read(Class<?> cls); OpenAPI read(Set<Class<?>> classes); @Override void setConfiguration(OpenAPIConfiguration openApiConfiguration); @Override OpenAPI read(Set<Class<?>> classes, Map<String, Object> resources); OpenAPI read(Class<?> cls,
                        String parentPath,
                        String parentMethod,
                        boolean isSubresource,
                        RequestBody parentRequestBody,
                        ApiResponses parentResponses,
                        Set<String> parentTags,
                        List<Parameter> parentParameters,
                        Set<Class<?>> scannedResources); Operation parseMethod(
            Method method,
            List<Parameter> globalParameters,
            JsonView jsonViewAnnotation); Operation parseMethod(
            Method method,
            List<Parameter> globalParameters,
            Produces methodProduces,
            Produces classProduces,
            Consumes methodConsumes,
            Consumes classConsumes,
            List<SecurityRequirement> classSecurityRequirements,
            Optional<io.swagger.v3.oas.models.ExternalDocumentation> classExternalDocs,
            Set<String> classTags,
            List<io.swagger.v3.oas.models.servers.Server> classServers,
            boolean isSubresource,
            RequestBody parentRequestBody,
            ApiResponses parentResponses,
            JsonView jsonViewAnnotation,
            io.swagger.v3.oas.annotations.responses.ApiResponse[] classResponses); Operation parseMethod(
            Method method,
            List<Parameter> globalParameters,
            Produces methodProduces,
            Produces classProduces,
            Consumes methodConsumes,
            Consumes classConsumes,
            List<SecurityRequirement> classSecurityRequirements,
            Optional<io.swagger.v3.oas.models.ExternalDocumentation> classExternalDocs,
            Set<String> classTags,
            List<io.swagger.v3.oas.models.servers.Server> classServers,
            boolean isSubresource,
            RequestBody parentRequestBody,
            ApiResponses parentResponses,
            JsonView jsonViewAnnotation,
            io.swagger.v3.oas.annotations.responses.ApiResponse[] classResponses,
            AnnotatedMethod annotatedMethod); void setApplication(Application application); static final String DEFAULT_MEDIA_TYPE_VALUE; static final String DEFAULT_DESCRIPTION; }