github.com/tickoalcantara12/micro/v3@v3.0.0-20221007104245-9d75b9bcbab9/cmd/protoc-gen-openapi/converter/schema_paths_test.go (about)

     1  package converter
     2  
     3  import (
     4  	"testing"
     5  
     6  	"github.com/stretchr/testify/assert"
     7  )
     8  
     9  func TestSchemaPaths(t *testing.T) {
    10  
    11  	// URL path (including service-name, proto-service, and method):
    12  	assert.Equal(t, "/tests/schemaPaths/urlPath", urlPath("tests", "schemaPaths", "urlPath"))
    13  
    14  	// Service name (last word in a dot-delimited string):
    15  	assert.Equal(t, "schemapaths", protoServiceName("tests.schemapaths"))
    16  
    17  	// How to find a message schema in an OpenAPI spec:
    18  	assert.Equal(t, "#/components/schemas/urlPathPayload", messageSchemaPath("urlPathPayload"))
    19  
    20  	// The name of a request body schema:
    21  	assert.Equal(t, "schemaPathsurlPathRequest", requestBodyName("schemaPaths", "urlPath"))
    22  
    23  	// How to find a request body schema in an OpenAPI spec:
    24  	assert.Equal(t, "#/components/requestBodies/schemaPathsurlPathRequest", requestBodySchemaPath("schemaPathsurlPathRequest"))
    25  
    26  	// The name of a response body schema:
    27  	assert.Equal(t, "schemaPathsurlPathResponse", responseBodyName("schemaPaths", "urlPath"))
    28  
    29  	// How to find a response body schema in an OpenAPI spec:
    30  	assert.Equal(t, "#/components/responses/schemaPathsurlPathResponse", responseBodySchemaPath("schemaPathsurlPathResponse"))
    31  }