OpenAPITools / OpenAPITools/openapi-diff

ChangedSchema in a readOnly property for requestBody is not filtered out from the result.

Offen
#357 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Vorherrschende Sprache
Java
Sterne
1.1k
Forks
190
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

Old API
{
  "openapi":"3.0.0",
  "info":{
    "title":"API",
    "version":"0.1.0"
  },
  "paths":{
    "/resource":{
      "post":{
        "responses":{
          "200":{
            "description":"Created resource",
            "content":{
              "application/json":{
                "schema":{
                  "$ref":"#/components/schemas/CreateResourceResponse"
                }
              }
            }
          }
        },
        "summary":"Create resource",
        "requestBody":{
          "content":{
            "application/json":{
              "schema":{
                "$ref":"#/components/schemas/CreateResourceRequest"
              }
            }
          },
          "description":"Definition of the resource"
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateResourceResponse": {
        "type": "object",
        "properties": {
          "resources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "CreateResourceRequest": {
        "type": "object",
        "properties": {
          "foo": {
            "$ref": "#/components/schemas/Foo"
          }
        }
      },
      "Foo": {
        "type": "object",
        "properties": {
          "bar": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Bar"
            },
            "readOnly": true
          }
        }
      },
      "Bar": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          }
        }
      }
    }
  }
}
New API
{
  "openapi":"3.0.0",
  "info":{
    "title":"API",
    "version":"0.1.0"
  },
  "paths":{
    "/resource":{
      "post":{
        "responses":{
          "200":{
            "description":"Created resource",
            "content":{
              "application/json":{
                "schema":{
                  "$ref":"#/components/schemas/CreateResourceResponse"
                }
              }
            }
          }
        },
        "summary":"Create resource",
        "requestBody":{
          "content":{
            "application/json":{
              "schema":{
                "$ref":"#/components/schemas/CreateResourceRequest"
              }
            }
          },
          "description":"Definition of the resource"
        }
      }
    }
  },
  "components": {
    "schemas": {
      "CreateResourceResponse": {
        "type": "object",
        "properties": {
          "resources": {
            "type": "array",
            "items": {
              "type": "string"
            }
          }
        }
      },
      "CreateResourceRequest": {
        "type": "object",
        "properties": {
          "foo": {
            "$ref": "#/components/schemas/Foo"
          }
        }
      },
      "Foo": {
        "type": "object",
        "properties": {
          "bar": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Bar"
            },
            "readOnly": true
          }
        }
      },
      "Bar": {
        "type": "object",
        "properties": {
          "name": {
            "type": "integer"
          }
        }
      }
    }
  }
}

In this example, the property bar in Foo schema is a readOnly property and Foo is referenced by request body of the endpoint.
When Bar schema is changed, it's filtered out from the request body but the change exists in the list of ChangedSchema in ChangedOpenApi, which results incompatible changes but shows nothing.

==========================================================================
==                            API CHANGE LOG                            ==
==========================================================================
                                   API                                    
--------------------------------------------------------------------------
--                                Result                                --
--------------------------------------------------------------------------
                 API changes broke backward compatibility                 
--------------------------------------------------------------------------

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Beginne damit, das Problem mit den Beispielen für Old API und New API zu reproduzieren, wobei du dich auf die ChangedSchema- und ChangedOpenApi-Ergebnisse für die readOnly-Bar-Eigenschaft im Request-Body konzentrierst. Verfolge, wie das geänderte Bar-Schema aus den Kompatibilitätsprüfungen für den Request-Body herausgefiltert wird, aber in ChangedSchema verbleibt; als abgeschlossen gilt die Arbeit, wenn die resultierende Änderungsliste und die Kompatibilitätsausgabe diese gefilterte Änderung nicht mehr melden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
java
Bereich
api, backend-api-design
Issue-Typ
Bug
Schwierigkeit
4/5
Geschätzter Aufwand
3-5 Tage
Aktivitätsstatus
Veraltet
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
48/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.