Skip to content

Backwards compatibility break in v0.36.4 and up #575

@boekkooi-impossiblecloud

Description

Good day,

Today I was updating one of our project to v0.37.0 and hit an issue where a lot of allOf where suddenly appearing.
I tracked it issue down to v0.36.4 which seems to break backward compatibility, the following test works with v0.36.3 but fails with v0.36.4.

Maybe you can point me in the right direction to fix this issue?
Thanks in advance and have a great day 😄

package openapi

import (
	"testing"

	"github.com/pb33f/libopenapi"
	"github.com/stretchr/testify/assert"
	"github.com/stretchr/testify/require"
)

func TestAllOf(t *testing.T) {
	docYAML := `openapi: 3.1.2
paths: {}
components:
    schemas:
        Timestamp:
            $schema: https://spec.openapis.org/oas/3.1/dialect/base
            type: string
            title: Timestamp
            format: date-time
        cmd.protoc_gen_go.testdata.proto.GetShipperRequest:
            $schema: https://spec.openapis.org/oas/3.1/dialect/base
            type: object
            properties:
                name:
                    type: string
                    description: |-
                        The resource name of the shipper to retrieve.
                         Format: shippers/{shipper}
            title: Get Shipper Request
            required:
                - name
            additionalProperties: true
            description: Request message for FreightService.GetShipper.
        cmd.protoc_gen_go.testdata.proto.Shipper:
            $schema: https://spec.openapis.org/oas/3.1/dialect/base
            type: object
            properties:
                name:
                    type: string
                    description: The resource name of the shipper.
                createTime:
                    $ref: '#/components/schemas/Timestamp'
                    description: The creation timestamp of the shipper.
                updateTime:
                    $ref: '#/components/schemas/Timestamp'
                    title: The last update timestamp of the shipper.
                    description: Updated when create/update/delete operation is performed.
                deleteTime:
                    $ref: '#/components/schemas/Timestamp'
                    description: The deletion timestamp of the shipper.
                displayName:
                    type: string
                    description: The display name of the shipper.
                billingAccount:
                    type: string
                    description: The billing account of the shipper.
                etag:
                    type: string
                    description: The current etag value of the shipper.
            title: Shipper
            required:
                - billingAccount
                - displayName
                - name
            additionalProperties: true
            description: A shipper is a supplier or owner of goods to be transported.
`

	doc, err := libopenapi.NewDocument([]byte(docYAML))
	require.NoError(t, err)

	model, err := doc.BuildV3Model()
	require.NoError(t, err)

	modelBytes, err := model.Model.Render()
	require.NoError(t, err)

	assert.Equal(t, docYAML, string(modelBytes))
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions