Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
Maksim Orlov
@MaksimOrlov
source code
if it is possible
Jaroslav Sagan
@SaganJaro_twitter
@ApiModel("ServiceRequest")
data class ServiceRequest(
    val id: UUID = UUID.randomUUID(),
    val createdAt: OffsetDateTime,
    val lastModifiedAt: OffsetDateTime?,
    val followUpDueAt: OffsetDateTime?,
    var description: String,
    val type: ServiceRequestType,
    val status: ServiceRequestStatus,

    @get:Valid
    @get:JsonInclude(JsonInclude.Include.ALWAYS)
    val participants: List<Participant> = emptyList(),

    @get:JsonInclude(JsonInclude.Include.ALWAYS)
    val documents: List<Document> = emptyList()
)
here is one of classes which has the issue with Req/Res. It is a standard data class, I know it is Kotlin but we did not had this issue in the previous version.
Maksim Orlov
@MaksimOrlov
could you also provide swagger result listing for both ServiceRequestRes and ServiceRequestReq
Jaroslav Sagan
@SaganJaro_twitter
{
    "ServiceRequestReq": {
        "type": "object",
        "required": [
            "status",
            "type"
        ],
        "properties": {
            "createdAt": {
                "type": "string",
                "format": "date-time"
            },
            "description": {
                "type": "string"
            },
            "documents": {
                "type": "array",
                "items": {
                    "$ref": "#/definitions/DocumentReq"
                }
            },
            "followUpDueAt": {
                "type": "string",
                "format": "date-time"
            },
            "id": {
                "type": "string",
                "format": "uuid"
            },
            "lastModifiedAt": {
                "type": "string",
                "format": "date-time"
            },
            "participants": {
                "type": "array",
                "items": {
                    "$ref": "#/definitions/ParticipantReq"
                }
            },
            "status": {
                "type": "string",
                "enum": [
                    "ABANDONED",
                    "DONE",
                    "PENDING"
                ]
            },
            "type": {
                "type": "string",
                "enum": [
                    ""
                ]
            }
        },
        "title": "ServiceRequestReq"
    },
    "ServiceRequestRes": {
        "type": "object",
        "required": [
            "documents",
            "id",
            "participants",
            "status",
            "type"
        ],
        "properties": {
            "createdAt": {
                "type": "string",
                "format": "date-time"
            },
            "description": {
                "type": "string"
            },
            "documents": {
                "type": "array",
                "items": {
                    "$ref": "#/definitions/DocumentRes"
                }
            },
            "followUpDueAt": {
                "type": "string",
                "format": "date-time"
            },
            "id": {
                "type": "string",
                "format": "uuid"
            },
            "lastModifiedAt": {
                "type": "string",
                "format": "date-time"
            },
            "participants": {
                "type": "array",
                "items": {
                    "$ref": "#/definitions/ParticipantRes"
                }
            },
            "status": {
                "type": "string",
                "enum": [
                    "ABANDONED",
                    "DONE",
                    "PENDING"
                ]
            },
            "type": {
                "type": "string",
                "enum": [
                    ""
                ]
            }
        },
        "title": "ServiceRequestRes"
    }
}
interesting that required is different even though it is the same object defined in the API
could it be somehow related to Kotlin and nullability/ default values?
Maksim Orlov
@MaksimOrlov
yes, it could be definitely related to Kotlin types. The required section is taken to consideration while comparing two representations of one type.
Jarvan Gong
@jarvan4dev
Hello, it seems that swagger3.0 not suppoort https protocol?
Yusuf Aran
@ysfaran

Hey guys!

i am currently building a prototype for a small app using spring boot and springfox + swagger-ui, where i maintain orders and products.
Everything worked fine until i added a @OneToOne self-relationship to an order, which means every order can have a parent order.

This is my POJO entity class:

package de.gloam.prototype.kelkoch.entities;

import de.gloam.prototype.kelkoch.constants.OrderState;
import lombok.Data;

import javax.persistence.*;
import java.util.Date;
import java.util.Set;

@Data
@Entity(name = "Order")
@Table(name="orders")
public class Order {
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Column(name = "id", updatable = false, nullable = false)
    public Long id;

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name= "parent_order")
    public Order parentOrder;

    @Column(name = "table_number")
    public int tableNumber;

    @Column(name = "order_state")
    public OrderState orderState = OrderState.ORDERED;

    @Column(name = "ordered_at")
    public Date orderedAt;

    @ManyToMany
    @JoinTable(
        name = "order_product",
        joinColumns = @JoinColumn(name = "order_id"),
        inverseJoinColumns = @JoinColumn(name = "product_id")
    )
    public Set<Product> products;
}

When i run the app i get following error:

java.lang.IllegalStateException: Ambiguous models equality when conditions is empty.
    at springfox.documentation.spring.web.scanners.ApiModelReader.checkCondition(ApiModelReader.java:618) ~[springfox-spring-web-3.0.0.jar:3.0.0]
    at springfox.documentation.spring.web.scanners.ApiModelReader.mergeConditions(ApiModelReader.java:385) ~[springfox-spring-web-3.0.0.jar:3.0.0]
    at springfox.documentation.spring.web.scanners.ApiModelReader.mergeModelBranch(ApiModelReader.java:255) ~[springfox-spring-web-3.0.0.jar:3.0.0]
    at springfox.documentation.spring.web.scanners.ApiModelReader.lambda$mergeModelBranch$6(ApiModelReader.java:197) ~[springfox-spring-web-3.0.0.jar:3.0.0]
    at java.base/java.util.Optional.orElseGet(Optional.java:362) ~[na:na]
    at springfox.documentation.spring.web.scanners.ApiModelReader.mergeModelBranch(ApiModelReader.java:197) ~[springfox-spring-web-3.0.0.jar:3.0.0]
    at springfox.documentation.spring.web.scanners.ApiModelReader.lambda$mergeModelBranch$6(ApiModelReader.java:197) ~[springfox-spring-web-3.0.0.jar:3.0.0]
    at java.base/java.util.Optional.orElseGet(Optional.java:362) ~[na:na]
    at springfox.documentation.spring.web.scanners.ApiModelReader.mergeModelBranch(ApiModelReader.java:197) ~[springfox-spring-web-3.0.0.jar:3.0.0]
    at springfox.documentation.spring.web.scanners.ApiModelReader.lambda$read$2(ApiModelReader.java:145) ~[springfox-spring-web-3.0.0.jar:3.0.0]
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.accept(ForEachOps.java:183) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline$2$1.accept(ReferencePipeline.java:177) ~[na:na]
    at java.base/java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1624) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:484) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:474) ~[na:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:150) ~[na:na]
    at java.base/java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:173) ~[na:na]
    at java.base/java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234) ~[na:na]
    at java.base/java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:497) ~[na:na]
    at springfox.documentation.spring.web.scanners.ApiModelReader.read(ApiModelReader.java:145) ~[springfox-spring-web-3.0.0.jar:3.0.0]
    at springfox.documentation.spring.web.scanners.ApiListingScanner.scan(ApiListingScanner.java:154) ~[springfox-spring-web-3.0.0.jar:3.0.0]
    at springfox.documentation.spring.web.scanners.ApiDocumentationScanner.scan(ApiDocumentationScanner.java:67) ~[springfox-spring-web-3.0.0.jar:3.0.0]
    at springfox.documentation.spring.web.plugins.Abstr
image.png

The app is still running but swagger-ui.html is not displaying properly.

When i remove this:

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name= "parent_order")
    public Order parentOrder;

The swagger ui works again.

What could be the issue here? I did quite a lot of googling but couldn't find a solution..

ANY HELP IS GREATLY APPRECIATED! :)

Yusuf Aran
@ysfaran

I just realized that it should be a @OneToMany/ @ManyToOne instead of a @OneToOne relationship:

// ----------ORIGINAL

    @OneToOne(cascade = CascadeType.ALL)
    @JoinColumn(name= "parent_order")
    public Order parentOrder;

// ---------- REPLACED WITH
    @ManyToOne(cascade = CascadeType.ALL)
    @JoinColumn(name= "parent_order")
    public Order parentOrder;

    @OneToMany(mappedBy = "parentOrder")
    public Set<Order> subOrders  = new HashSet<Order>();

But it's still the same error..

Datta Akeshwar
@aakidatta_twitter
Hi there. Have anyone used "springfox-openapi" swagger generation with "Extensible Enum"? Any help is greatly appreciated!
saagar2000
@saagar2000
I'm trying to use spring mock mvc with web app configuration to load the web application context and test my controller - What is the swagger set up for these tests ? do not load or mock swagger ?
WhiteHatTux
@WhiteHatTux
@jbq @dilipkrish In November 2016 you were talking about the integration of protobuf and springfox/swagger. Around here: https://gitter.im/springfox/springfox?at=581ca7056cb720763036be42
Did you ever get to resolve it via plugin or hack? :-)
I got protobuf to be shown in swagger-ui, but it includes all getters and setters of the generated java class (and thus hangs for about 30 seconds when loading the page). Is there a possibility to use the json representation in model/example.
so technically everything is working as of now, as the /v2/api-docs are generated (>60 KB for an API with about <30 Put/GetMappings) and are read by swagger-ui successfully. But the example and model data is almost useless, as it is full of generated helper getters and setters in protobuf. And the page loads veeeeery slowly. :-)
WhiteHatTux
@WhiteHatTux
I am using io.springfox:springfox-boot-starter:3.0.0 and com.google.protobuf:protobuf-java:3.14.0
Actually measuring it the loading time has improved a lot compared to my previous tests, but the content is still almost useless.
WhiteHatTux
@WhiteHatTux
I managed to get it working with https://github.com/innogames/springfox-protobuf
Dilip Krishnan
@dilipkrish
That’s awesome @WhiteHatTux ! I’ll take a look at it. Thanks for sharing !
@ysfaran what version of springFox are you using. Seems like you’re not on 3.0. If so perhaps @MaksimOrlov might be able to help
@aakidatta_twitter what are you trying to do. Perhaps an example would help
Yusuf Aran
@ysfaran
@dilipkrish
Thats my pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.4.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>some.groupId</groupId>
    <artifactId>someArtifact</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>someName</name>
    <description>someDescription</description>

    <properties>
        <java.version>11</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-websocket</artifactId>
        </dependency>

        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>

        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.junit.vintage</groupId>
                    <artifactId>junit-vintage-engine</artifactId>
                </exclusion>
            </exclusions>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-swagger-ui</artifactId>
            <version>2.10.5</version>
        </dependency>

        <dependency>
            <groupId>io.springfox</groupId>
            <artifactId>springfox-boot-starter</artifactId>
            <version>3.0.0</version>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>
fqtx
@fqtx
class path resource [springfox/documentation/spring/web/SpringfoxWebConfiguration.class] cannot be opened because it does not exist
renatoc1
@renatoc1
class path resource [springfox/documentation/swagger2/web/Swagger2Controller.class] cannot be opened because it does not exist
NABGC
@NABGC
when started spring boot project ,the console print "Validator -ERROR [ModelSpecification.spec] At least one type of specification is required" , and I'm using latest version.how to fix it ?
Andrew Holland
@a1dutch
@dilipkrish any reason why the https://github.com/webjars/swagger-ui couldnt be used rather than packaging this up in the build? this would allow the ui to be updated with the latest changes without a new release of springfox!
Harikesh Pallantla
@harikesh409
hi all,
I am using sprinfox-boot-starter v3.0.0 and in swagger ui an endpoint /foo/{id} is missing but if I change the endpoint to /foo/{id}/ I am able to get it, can anyone tell me where I might go wrong.
1 reply
Dilip Krishnan
@dilipkrish
Can’t tell without a reproducible sample. @harikesh409
@a1dutch that’s because it has customizations that discover swagger endpoints so that you don’t have to type the endpoint in the ui.
Harikesh Pallantla
@harikesh409

Can’t tell without a reproducible sample. @harikesh409

If I remove spring-boot-starter-data-rest this dependency it is working properly, I will deploy somewhere and give a sample if possible. Can you say if any dependency that might cause a conflict?

Dilip Krishnan
@dilipkrish
It’s very possible that something is causing that endpoint to go away from the documentation. Would be great if you have a working sample that shows it’s missing. I could then try and fix it.
czephyr
@czephyr
can someone clarify for me how am I supposed to use Swagger with a Maven Project using only Servlets?
is it even possible?
Dilip Krishnan
@dilipkrish
Depends. SpringFox only supports spring based api discovery. If your application is completely hand written using servlets then you’re better off writing the open api docs by hand
czephyr
@czephyr

`
@WebServlet("/home")
public class HomeController extends HttpServlet {

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
PrintWriter out = response.getWriter();
UserDAO uDao = new UserDAO();
ArrayList<Customer> customers = null;

    response.setContentType("application/json");
    response.setCharacterEncoding("UTF-8");

    try {
        customers=uDao.doRetrieveAll();

    } catch (SQLException throwables) {
        throwables.printStackTrace();
    } finally {
        out.print(new Gson().toJson(customers));
        out.flush();
    }
}

}
`

well I tried my best to fit it all in
this is an example of one of the many endpoints in my project
the webservlet tag is the only javaee tag I'm making use of
@dilipkrish would you say in this instance its not worth to use Swagger? If its not would you mind directing me towards any other cool way I can document my api? thank you
Dilip Krishnan
@dilipkrish
In this particular case I’d check to see if swagger-core would support it. Tho I think that project is also geared towards jax-rs. My recommendation would be to use spring-rest-docs if you have tests that excercise this endpoint.
czephyr
@czephyr

In this particular case I’d check to see if swagger-core would support it. Tho I think that project is also geared towards jax-rs. My recommendation would be to use spring-rest-docs if you have tests that excercise this endpoint.

would you mind clearing up for me what is JAX-RS? I seem to not be able to figure it out. I understand that JavaEE offers many way to write web apps easily, are Servlets part of JAX-RS?

Andrew Holland
@a1dutch
Hi, is it possible to configure v3 to use swagger2 via the ui via properties? the ui keeps looking for /v3/api-docs
3 replies
Can Emre Ayar
@justayar

Hi all,
I am using io.springfox 3.0.0 version in my project. I added the dependency to my build.gradle file as following:

implementation group: 'io.springfox', name: 'springfox-boot-starter', version: '3.0.0'

The external libraries were created as expected:

io.springfox:springfox-boot-starter:3.0.0
io.springfox:springfox-core:3.0.0
io.springfox:springfox-data-rest:3.0.0
io.springfox:springfox-oas:3.0.0
io.springfox:springfox-schema:3.0.0
io.springfox:springfox-spi:3.0.0
io.springfox:springfox-spring-web:3.0.0
io.springfox:springfox-spring-web-flux:3.0.0
io.springfox:springfox-spring-web-mvc:3.0.0
io.swagger.core.v3:swagger-annotation:2.1.2
io.swagger.core.v3:swagger-models:2.1.2
I am using Spring Boot 2.4.2 and Java 11.

When I run my Spring boot application, I get the following error:

org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'swagger2ControllerWebMvc' defined in URL [jar:file:/opt/rally/dynamicscreen-service/lib/springfox-swagger2.jar!/springfox/documentation/swagger2/web/Swagger2ControllerWebMvc.class]: Unsatisfied dependency expressed through constructor parameter 2; nested exception is org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'jsonSerializer' defined in springfox.documentation.spring.web.SpringfoxWebConfiguration: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [springfox.documentation.spring.web.json.JsonSerializer]: Factory method 'jsonSerializer' threw exception; nested exception is java.lang.NoClassDefFoundError: io/swagger/v3/oas/models/OpenAPI

Where could I be doing wrong?

kumarsen26
@kumarsen26
Hi,
I am using springdoc-openapi-webflux-ui (v1.5.6). I have a microservice with different endpoints.
I am not able to maintain the order of the endpoints (I dont want it to sort on alphabetically method or tags).
is there a way??
 @Operation(description = "first endpoint ", requestBody = @io.swagger.v3.oas.annotations.parameters.RequestBody())
bghazy
@ghazy17_twitter
Hello all ,
After updating io.springfox to version 3.0.0 in my spring boot project ... I remarked that the order of values of Enum used as parameter in a post method changed to asc alphabetic in api-docs
Do you know what could cause this ?
Thank you for your help :)
Vu Do
@VuDo98
Hi guys. Is there anyway to change the style of an array request param? It was generating the style as form but now it turns into pipe delimited even though I haven't changed any settings.
I use spring fox 3.0