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

Open-api fix #115

Merged
merged 1 commit into from
Oct 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ See [Conventional Commits](https://conventionalcommits.org) for commit guideline
### Features

* Bump SNAPSHOT version to 4.12.3 [#114](https://github.com/hyperledger/web3j-openapi/pull/114)
* Updated Libs, refactored code, fixed tests [#115](https://github.com/hyperledger/web3j-openapi/pull/115)

### BREAKING CHANGES

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
package org.web3j.openapi.client

import javax.ws.rs.client.ClientRequestContext
import javax.ws.rs.client.ClientRequestFilter
import javax.ws.rs.core.HttpHeaders
import jakarta.ws.rs.client.ClientRequestContext
import jakarta.ws.rs.client.ClientRequestFilter
import jakarta.ws.rs.core.HttpHeaders

class AuthenticationFilter private constructor(private val token: String) : ClientRequestFilter {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
package org.web3j.openapi.client

import jakarta.ws.rs.ClientErrorException
import jakarta.ws.rs.core.MediaType
import org.web3j.openapi.core.ErrorResponse
import javax.ws.rs.ClientErrorException
import javax.ws.rs.core.MediaType

/**
* Client API exception containing error data.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@
*/
package org.web3j.openapi.client

import jakarta.ws.rs.ClientErrorException
import jakarta.ws.rs.client.WebTarget
import jakarta.ws.rs.sse.SseEventSource
import mu.KLogging
import java.lang.reflect.InvocationHandler
import java.lang.reflect.InvocationTargetException
Expand All @@ -21,9 +24,6 @@ import java.lang.reflect.Proxy
import java.net.URL
import java.util.concurrent.CompletableFuture
import java.util.function.Consumer
import javax.ws.rs.ClientErrorException
import javax.ws.rs.client.WebTarget
import javax.ws.rs.sse.SseEventSource

/**
* Invocation handler for proxied resources.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import com.fasterxml.jackson.annotation.Nulls
import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import jakarta.ws.rs.client.Client
import jakarta.ws.rs.client.ClientBuilder
import org.glassfish.jersey.client.ClientConfig
import org.glassfish.jersey.client.ClientProperties
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.Annotations
Expand All @@ -25,8 +27,6 @@ import org.glassfish.jersey.logging.LoggingFeature
import org.slf4j.bridge.SLF4JBridgeHandler
import java.util.logging.Level
import java.util.logging.Logger
import javax.ws.rs.client.Client
import javax.ws.rs.client.ClientBuilder

class ClientService @JvmOverloads constructor(
val uri: String,
Expand Down
1 change: 0 additions & 1 deletion codegen/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ dependencies {
}

implementation "com.pinterest.ktlint:ktlint-ruleset-standard:${versions.ktlint}"
implementation "com.pinterest.ktlint:ktlint-ruleset-experimental:${versions.ktlint}"
implementation("org.openapitools:openapi-generator:${versions.openApiGenerator}") {
exclude group: 'com.github.jknack'
exclude group: 'javax.activation'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
package org.web3j.openapi.codegen.utils

import com.pinterest.ktlint.core.KtLint
import com.pinterest.ktlint.ruleset.experimental.ExperimentalRuleSetProvider
import com.pinterest.ktlint.ruleset.standard.StandardRuleSetProvider
import mu.KLogging
import java.io.File
Expand All @@ -23,10 +22,7 @@ import java.nio.file.StandardCopyOption

internal object CopyUtils : KLogging() {

private val ruleSets = listOf(
StandardRuleSetProvider().get(),
ExperimentalRuleSetProvider().get(),
)
private val ruleProvider = StandardRuleSetProvider().getRuleProviders()

fun copyResource(name: String, outputDir: File) {
Files.copy(
Expand All @@ -51,14 +47,16 @@ internal object CopyUtils : KLogging() {
* Format a given Kotlin file using KtLint.
*/
fun kotlinFormat(file: File) {
KtLint.format(
KtLint.Params(
ruleSets = ruleSets,
cb = { _, _ -> },
val formattedText = KtLint.format(
KtLint.ExperimentalParams(
text = file.readText(),
ruleProviders = ruleProvider,
userData = mapOf(),
cb = { _, _ -> },
script = false,
debug = false,
),
).run {
file.writeText(this)
}
)
file.writeText(formattedText)
}
}
6 changes: 3 additions & 3 deletions core/src/main/kotlin/org/web3j/openapi/core/SubResource.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,9 @@
*/
package org.web3j.openapi.core

import javax.ws.rs.GET
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType
import jakarta.ws.rs.GET
import jakarta.ws.rs.Produces
import jakarta.ws.rs.core.MediaType

/**
* A Web3j OpenAPI can contain nested resources.
Expand Down
8 changes: 4 additions & 4 deletions core/src/main/kotlin/org/web3j/openapi/core/Web3jOpenApi.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@
*/
package org.web3j.openapi.core

import javax.ws.rs.Consumes
import javax.ws.rs.Path
import javax.ws.rs.Produces
import javax.ws.rs.core.MediaType
import jakarta.ws.rs.Consumes
import jakarta.ws.rs.Path
import jakarta.ws.rs.Produces
import jakarta.ws.rs.core.MediaType

/**
* Entry point for Web3j OpenAPIs.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ package org.web3j.openapi.server

import com.fasterxml.jackson.core.JsonParseException
import com.fasterxml.jackson.databind.JsonMappingException
import jakarta.servlet.http.HttpServletRequest
import jakarta.ws.rs.NotFoundException
import jakarta.ws.rs.core.Context
import jakarta.ws.rs.core.HttpHeaders
import jakarta.ws.rs.core.Response
import jakarta.ws.rs.core.Response.Status
import jakarta.ws.rs.core.Response.Status.Family
import jakarta.ws.rs.core.UriInfo
import jakarta.ws.rs.ext.ExceptionMapper
import org.eclipse.jetty.http.HttpStatus
import org.web3j.openapi.core.ErrorResponse
import org.web3j.protocol.exceptions.TransactionException
import org.web3j.tx.exceptions.ContractCallException
import javax.servlet.http.HttpServletRequest
import javax.ws.rs.NotFoundException
import javax.ws.rs.core.Context
import javax.ws.rs.core.HttpHeaders
import javax.ws.rs.core.Response
import javax.ws.rs.core.Response.Status
import javax.ws.rs.core.Response.Status.Family
import javax.ws.rs.core.UriInfo
import javax.ws.rs.ext.ExceptionMapper

sealed class BaseExceptionMapper<E : Throwable>(
private val status: Response.StatusType,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
*/
package org.web3j.openapi.server

import jakarta.ws.rs.core.Configuration
import jakarta.ws.rs.core.Context
import mu.KLogging
import org.glassfish.hk2.api.Factory
import org.web3j.crypto.Credentials
Expand All @@ -28,8 +30,6 @@ import org.web3j.protocol.http.HttpService
import org.web3j.tx.gas.ContractGasProvider
import org.web3j.tx.gas.DefaultGasProvider
import java.io.File
import javax.ws.rs.core.Configuration
import javax.ws.rs.core.Context

class Web3jFactory(
@Context private val configuration: Configuration,
Expand Down
6 changes: 3 additions & 3 deletions server/src/main/kotlin/org/web3j/openapi/server/SseUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
package org.web3j.openapi.server

import io.reactivex.Flowable
import jakarta.ws.rs.core.MediaType
import jakarta.ws.rs.sse.Sse
import jakarta.ws.rs.sse.SseEventSink
import mu.KLogging
import org.web3j.abi.datatypes.Event
import javax.ws.rs.core.MediaType
import javax.ws.rs.sse.Sse
import javax.ws.rs.sse.SseEventSink

object SseUtils : KLogging() {
fun <T, R> subscribe(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature
import com.fasterxml.jackson.databind.SerializationFeature
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource
import jakarta.inject.Singleton
import org.glassfish.hk2.utilities.binding.AbstractBinder
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.cfg.Annotations
import org.glassfish.jersey.jackson.internal.jackson.jaxrs.json.JacksonJaxbJsonProvider
Expand Down Expand Up @@ -45,7 +46,6 @@ import org.web3j.protocol.Web3j
import org.web3j.tx.gas.ContractGasProvider
import java.util.ServiceLoader
import java.util.logging.Logger
import javax.inject.Singleton

/**
* The JAX-RS application configuration.
Expand Down
12 changes: 6 additions & 6 deletions versions.properties
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
assertk=0.22
gradle=8.7
jackson=2.17.1
jersey=2.32
jetty=9.4.32.v20200930
jersey=3.1.8
jetty=11.0.23
kotlinLogging=3.0.5
kotlinPoet=1.18.1
ktlint=0.34.2
logback=1.5.6
ktlint=0.48.2
logback=1.5.8
mockitoJunit=3.1.0
openApiGenerator=4.0.3
openApiGenerator=6.6.0
picocli=4.7.6
slf4j=2.0.13
swagger=2.2.11
swagger=2.2.23
Loading