OpenAPITools / OpenAPITools/openapi-diff

Using a reference in items of array results in error

未关闭
#464 3 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@joschi 已经在做这个了。

开始于 2023年2月26日。

  • #470 来自 @joschi —— 未关闭
duplicate
主要语言
Java
星标
1.1k
派生
190
PR 合并指标
30 天内没有已合并 PR

描述

When a reference is used in items: of an array, e.g. :

type: object
description: Model for response from call to GET products requiring an array of products to be returned.
title: GetProductResponse
properties:
  Products:
    type: array
    items:
      $ref: Product.yaml

and error is thrown while resolving the references:

$ java -jar openapi-diff-cli-2.1.0-beta.4-all.jar --error --fail-on-incompatible source/specification/openapi.yaml destination/specification/openapi.yaml
Unexpected exception. Reason: Invalid ref: ./common/models/Product.yaml
java.lang.IllegalArgumentException: Invalid ref: ./common/models/Product.yaml
        at org.openapitools.openapidiff.core.utils.RefPointer.getRefName(RefPointer.java:60)
        at org.openapitools.openapidiff.core.utils.RefPointer.resolveRef(RefPointer.java:16)
        at org.openapitools.openapidiff.core.compare.SchemaDiff.computeDiffForReal(SchemaDiff.java:337)
        at org.openapitools.openapidiff.core.model.deferred.DeferredSchemaCache.processSchemaQueue(DeferredSchemaCache.java:86)
        at org.openapitools.openapidiff.core.model.deferred.DeferredSchemaCache.process(DeferredSchemaCache.java:64)
        at org.openapitools.openapidiff.core.compare.OpenApiDiff.compare(OpenApiDiff.java:100)
        at org.openapitools.openapidiff.core.compare.OpenApiDiff.compare(OpenApiDiff.java:64)
        at org.openapitools.openapidiff.core.OpenApiCompare.fromSpecifications(OpenApiCompare.java:102)
        at org.openapitools.openapidiff.core.OpenApiCompare.fromLocations(OpenApiCompare.java:91)
        at org.openapitools.openapidiff.cli.Main.main(Main.java:175)

Files GetProductResponse.yaml and Product.yaml both reside in the same directory.

Attachment contains the source and destination folders, which contain a copy of the same openapi spec.
example.zip

贡献指南

打开贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

调研方向

从附加的 example.zip 开始并复现 CLI 命令;然后阅读 RefPointer.java,尤其是 getRefName 和 resolveRef,以及 trace 中提到的 SchemaDiff 和 DeferredSchemaCache 调用路径。当数组项的 sibling-file $ref 在没有 Invalid ref 异常的情况下完成解析且比较完成时,即视为完成。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
api
Issue 类型
缺陷
难度
3/5
预计耗时
1-2 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。