swagger-api / swagger-play

Apache License 2.0
331 stars 180 forks source link

Upgrade to Play Framework 2.8 #220

Open tarmath opened 4 years ago

tarmath commented 4 years ago

Upgrade to Play Framework 2.8

tarmath commented 4 years ago

@webron @frantuma Can I get one of you to take a quick peek at this PR?

We've been using these changes internally for a couple weeks now without any issues. Happy to adjust this as you see fit!

Much Appreciated!

tarmath commented 4 years ago

resolves https://github.com/swagger-api/swagger-play/issues/213

targeter commented 4 years ago

any chance this will be merged soon? @tarmath did you happen to try cross-compilation to Scala 2.13?

tarmath commented 4 years ago

@targeter cross compilation works great.

gaeljw commented 4 years ago

No offence but what are we waiting to merge this?

targeter commented 4 years ago

@webron @frantuma please take some action on this?

tarmath commented 4 years ago

@frantuma @webron could you guys please take a minute and let us know whether this project has been abandoned? perhaps that may lead to someone else rising up, forking and taking over maintenance / development of it?

much appreciated!

webron commented 4 years ago

@tarmath it's not that it is abandoned as much as a capacity problem. I've tried reaching out to a few people in the community to become committers, but unfortunately have managed to get nobody yet. If anyone is interested, feel free to drop me a line (email in profile).

arunzn commented 4 years ago

Can you please merge it asap and release it for public use ?

JayZYan commented 4 years ago

Anyone is going to merge this?

gaeljw commented 4 years ago

Note that the plugin works fine with Play Framework 2.8 even though this PR is not merged. We have been running on the latest play-swagger release and Play Framework 2.8 for months now without issues.

tolomaus commented 4 years ago

Hi @gaeljw,

I did exactly what you suggested but I ran into an issue with fasterxml: it's throwing an error while generating the swagger.json because of a cyclic dependency on the StringProperty's readOnly method:

    public StringProperty readOnly() {
        this.setReadOnly(Boolean.TRUE);
        return this;
    }

I guess it's because it returns itself.

I found a similar unresolved issue on SO: https://stackoverflow.com/questions/62127929/swagger-ui-with-play-framework

I wonder why it worked just fine for you.

I'm currently on Play 2.8.2

Other verions: io.swagger:swagger-annotations:1.5.22 io.swagger:swagger-core:1.5.22 io.swagger:swagger-models:1.5.22 io.swagger:swagger-play2_2.12:1.7.1 io.swagger:swagger-scala-module_2.12:1.0.5 com.fasterxml.jackson.core:jackson-annotations:2.11.0 com.fasterxml.jackson.core:jackson-core:2.11.0 com.fasterxml.jackson.core:jackson-databind:2.10.5 com.fasterxml.jackson.dataformat:jackson-dataformat-cbor:2.10.3 com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:2.9.8 com.fasterxml.jackson.datatype:jackson-datatype-jdk8:2.10.5 com.fasterxml.jackson.datatype:jackson-datatype-jsr310:2.10.5 com.fasterxml.jackson.module:jackson-module-parameter-names:2.10.3 com.fasterxml.jackson.module:jackson-module-paranamer:2.10.3 com.fasterxml.jackson.module:jackson-module-scala_2.12:2.10.3

gaeljw commented 4 years ago

Hi @tolomaus , you should probably ensure that all Jackson dependencies are the same version (2.10.x, 2.11 doesn't work with Swagger AFAIK) with your build tool

tolomaus commented 4 years ago

@gaeljw I was finally able to work around the issue when I forced all fasterxml versions to 2.10.2!

Play 2.8.1 works fine out-of-the-box, but for Play 2.8.2 the fasterxml versions are bumped to 2.10.5 and that's when the issues surfaces.

I wonder why fasterxml 2.10.5 trips over the cyclic dependency, or rather, why 2.10.2 doesn't ;-)

holthauj commented 4 years ago

Here is a workaround that seems to resolve the cyclic dependency by ignoring the readOnly() method.

import io.swagger.models.properties.AbstractProperty;
import io.swagger.models.properties.Property;

static {
    ObjectMapper mapper = io.swagger.util.Json.mapper();
    mapper.addMixIn(AbstractProperty.class, AbstractPropertyMixin.class);
}

public static abstract class AbstractPropertyMixin {
    @JsonIgnore
    public abstract Property readOnly();
}
felipebonezi commented 3 years ago

@tarmath it's not that it is abandoned as much as a capacity problem. I've tried reaching out to a few people in the community to become committers, but unfortunately have managed to get nobody yet. If anyone is interested, feel free to drop me a line (email in profile).

Hi Webron, I want to help the community and become a committer. I've sent you an email. Please, let me help you guys!

P.S.: Merge this commit 🙏🏻

dwickern commented 3 years ago

I published my fork which cross-compiles for 2.7 and 2.8

// for Play 2.7:
libraryDependencies += "com.github.dwickern" %% "swagger-play2.7" % "3.0.0"

// for Play 2.8:
libraryDependencies += "com.github.dwickern" %% "swagger-play2.8" % "3.0.0"
cleliofs commented 3 years ago

Hi All,

Any idea when this PR will get merged back to swagger-api:master?

alejandrod-f commented 3 years ago

Waiting for this merge to start using it! thanks

AlexITC commented 2 years ago

@holthauj I ended up creating a java patch which solved a similar problem I had because a dependency is bringing jackson 2.11 to my classpath.

Tested with https://github.com/dwickern/swagger-play in play 2.8.7, thanks to @holthauj @dwickern


import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.swagger.models.properties.AbstractProperty;
import io.swagger.models.properties.Property;

// See https://github.com/swagger-api/swagger-play/pull/220#issuecomment-736987055
public class JavaJacksonPatch {
    static {
        ObjectMapper mapper = io.swagger.util.Json.mapper();
        mapper.addMixIn(AbstractProperty.class, AbstractPropertyMixin.class);
    }

    public static void init() {
        System.out.println("Applying jackson patch");
    }

    public static abstract class AbstractPropertyMixin {
        @JsonIgnore
        public abstract Property readOnly();
    }
}