【问题标题】:quarkus-smallrye-openapi - Could not resolve reference: Could not resolve pointer: /components/schemasquarkus-smallrye-openapi - 无法解析引用:无法解析指针:/components/schemas
【发布时间】:2021-04-14 17:22:42
【问题描述】:

我有一个休息端点,它使用一个类作为 openapi 架构:

import javax.ws.rs.Path;
import org.eclipse.microprofile.openapi.annotations.media.Schema;
import org.eclipse.microprofile.openapi.annotations.responses.APIResponse;

@Path("/orders")
@RequestScoped
public class OrdersRest {
        @APIResponse(responseCode = "200", description = "Create a new order", content = {
                        @Content(mediaType = "application/json", schema = @Schema(implementation = OrderDto.class)) })
        public Response create(OrderDto request) throws SessionNotFound {

OrderDto 类有一个属性引用了我的项目中存在的另一个类:

public class SessionDto {
    private SessionSettingsProperties[] sessionSettingsProperties;

当我访问 swagger-ui 时,我收到错误消息:

Errors
 
Resolver error at paths./session.get.responses.200.content.application/json.schema.properties.sessionSettingsProperties.items.$ref

Could not resolve reference: Could not resolve pointer: /components/schemas/SessionSettingsProperties does not exist in document

我使用的是 Quarkus 1.13.1.Final 版本。

我发现这个issue in Quarkus project 看起来很相似,但我相信这与我遇到的问题不完全相同。

【问题讨论】:

    标签: swagger-ui openapi quarkus


    【解决方案1】:

    我能够解决我的问题,包括我的 SessionDto 类字段中的一个 org.eclipse.microprofile.openapi.annotations.media.Schema 注释,如下所示:

    import org.eclipse.microprofile.openapi.annotations.media.Schema;
    
    public class SessionDto {
    
        @Schema(implementation = SessionSettingsProperties[].class)
        private SessionSettingsProperties[] sessionSettingsProperties;
    

    【讨论】:

    • 看起来 smallrye-openapi 没有正确扫描阵列,我已经打开了这个问题 github.com/smallrye/smallrye-open-api/issues/779 并且他们提出了一个 PR 来解决这个问题。我猜 1.13.2.Final 之后的下一个 Quarkus 版本会有这个。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-12-19
    • 1970-01-01
    • 2019-07-22
    • 2021-10-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多