openapi-changes icon indicating copy to clipboard operation
openapi-changes copied to clipboard

Bad handling of Yaml in diff around string

Open LasneF opened this issue 1 year ago • 1 comments

given the snippet

  schemas:
    Pet:
      type: object
      properties:
        id:
          readOnly: true
          type: string
        name:
          type: string
          enum: 
            - Bob

and this snippet

  schemas:
    Pet:
      type: object
      properties:
        id:
          readOnly: true
          type: string
        name:
          type: string
          enum: 
            - "Bob"

it is shown as differnt (add / remove) where this in yml stuff

LasneF avatar May 03 '24 09:05 LasneF

Will investigate

daveshanley avatar May 03 '24 16:05 daveshanley

The following test passes:

func TestCompareSchemas_CheckEnums(t *testing.T) {
	left := `openapi: 3.1.0
components:
  schemas:
    Pet:
      type: object
      properties:
        id:
          readOnly: true
          type: string
        name:
          type: string
          enum: 
            - Bob`

	right := `openapi: 3.1.0
components:
  schemas:
    Pet:
      type: object
      properties:
        id:
          readOnly: true
          type: string
        name:
          type: string
          enum: 
            - "Bob"`

	leftDoc, rightDoc := test_BuildDoc(left, right)

	// extract left reference schema and non reference schema.
	lSchemaProxy := leftDoc.Components.Value.FindSchema("Pet").Value
	rSchemaProxy := rightDoc.Components.Value.FindSchema("Pet").Value

	changes := CompareSchemas(lSchemaProxy, rSchemaProxy)
	assert.Nil(t, changes)
	assert.Equal(t, 0, changes.TotalChanges())

}

can you provide a working sample or is this fixed?

daveshanley avatar Feb 13 '25 02:02 daveshanley

fixed thanks to libOpenAPI changes ... woudl requires a release of openapic hanges with recent libopenapi

LasneF avatar Feb 13 '25 14:02 LasneF