swagger-play icon indicating copy to clipboard operation
swagger-play copied to clipboard

Upgrade to Play Framework 2.8

Open tarmath opened this issue 4 years ago • 20 comments

Upgrade to Play Framework 2.8

tarmath avatar Mar 01 '20 20:03 tarmath

@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 avatar Mar 01 '20 20:03 tarmath

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

tarmath avatar Mar 22 '20 22:03 tarmath

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

targeter avatar Mar 24 '20 08:03 targeter

@targeter cross compilation works great.

tarmath avatar Apr 24 '20 18:04 tarmath

No offence but what are we waiting to merge this?

gaeljw avatar Apr 29 '20 12:04 gaeljw

@webron @frantuma please take some action on this?

targeter avatar May 14 '20 08:05 targeter

@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!

tarmath avatar Jun 06 '20 17:06 tarmath

@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).

webron avatar Jun 08 '20 14:06 webron

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

arunzn avatar Oct 17 '20 16:10 arunzn

Anyone is going to merge this?

JayZYan avatar Oct 23 '20 02:10 JayZYan

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.

gaeljw avatar Oct 23 '20 06:10 gaeljw

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

tolomaus avatar Oct 24 '20 08:10 tolomaus

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

gaeljw avatar Oct 26 '20 07:10 gaeljw

@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 ;-)

tolomaus avatar Oct 26 '20 18:10 tolomaus

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();
}

holthauj avatar Dec 02 '20 04:12 holthauj

@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 🙏🏻

felipebonezi avatar Dec 04 '20 18:12 felipebonezi

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"

dwickern avatar Feb 04 '21 16:02 dwickern

Hi All,

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

cleliofs avatar Mar 08 '21 12:03 cleliofs

Waiting for this merge to start using it! thanks

alejandrod-f avatar Aug 02 '21 13:08 alejandrod-f

@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();
    }
}

AlexITC avatar Apr 02 '22 05:04 AlexITC