payara / Payara

Payara Server is an open source middleware platform that supports reliable and secure deployments of Java EE (Jakarta EE) and MicroProfile applications in any environment: on premise, in the cloud or hybrid.
http://www.payara.fish
Other
881 stars 303 forks source link

OpenAPI JAX-RS Incomplete subresource support /FISH-5808 #3042

Open vassterg opened 6 years ago

vassterg commented 6 years ago

Description


Incomplete support of openapi when subresource is present. I have two classes Foo and Bar such that Foo is a jaxrs resource and Bar is a subresource. When deployed, the openapi link is incomplete.

Expected Outcome

I would expect in the openapi link, the Bar sub resource GET endpoint to show up in the openapi and the Bar sub resource to be included as a schema.

Current Outcome

openapi: 3.0.0
info:
  title: Deployed Resources
  version: 1.0.0
servers:
- url: http://localhost:8080/openapi-test
  description: Default Server.
paths:
  /resources/foo:
    get:
      operationId: getMethod
      responses:
        default:
          description: Default Response.
          content:
            '*/*':
              schema:
                type: string
components: {}

No endpoint and schema for subresource bar.

Steps to reproduce (Only for bug reports)

Create a simple javaee 8 maven JAX-RS project. Example pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>com.insurit</groupId>
    <artifactId>openapi-test</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>
    <dependencies>
        <dependency>
            <groupId>javax</groupId>
            <artifactId>javaee-api</artifactId>
            <version>8.0</version>
            <scope>provided</scope>
        </dependency>
    </dependencies>
    <build>
        <finalName>openapi-test</finalName>
    </build>
    <properties>
        <maven.compiler.source>1.8</maven.compiler.source>
        <maven.compiler.target>1.8</maven.compiler.target>
        <failOnMissingWebXml>false</failOnMissingWebXml>
    </properties>
    <name>openapi-test</name>
</project>

Add the following three classes:

@ApplicationPath("resources")
public class JAXRSConfiguration extends Application {

}
@Path("foo")
public class Foo {

    @Context
    private ResourceContext rc;

    @GET
    public String getMethod() {
        return "get foo";
    }

    @Path("bar")
    public Bar sub() {
        return rc.getResource(Bar.class);
    }
}
public class Bar {

    @GET
    public Response barMethod() {
        return Response.ok().entity("bar").build();
    }
}

Build and deploy project. Then access http://localhost:8080/openapi

Samples

Context (Optional)

Environment

vassterg commented 6 years ago

Attached is a sample pmaven project and the final artifact for deployment

openapi-jaxrs-subresource-incomplete.zip openapi-incomplete.zip

MattGill98 commented 6 years ago

Hi @vassterg,

The current OpenAPI implementation doesn't support subresources. I've made an enhancement request PAYARA-3086 to add this functionality.

Kind regards,

Matt

smillidge commented 4 years ago

@jbee this is an old one do you think it will still be a problem?

jbee commented 4 years ago

@smillidge I believe we fixed this but I have to check.

jbee commented 4 years ago

@smillidge , @vassterg I was confusing this with another issue - @MattGill98 was and is correct in that we do not support subresources yet.

rdebusscher commented 4 years ago

Support for subresources is available in 5.194.

fschuerer commented 2 years ago

This does not work. I have tested it with the provided maven sample with Payara 5.2021.7. and 5.194 The path /resources/foo/bar is missing in the openapi doc.

rdebusscher commented 2 years ago

An internal issue is created to research the JAX-RS subresources and the OpenAPI document relation in detail.

Thx Rudy