Looks like support is missing in the upstream openapi library. Being worked on at https://github.com/pb33f/libopenapi/issues/25
A failing test.
›› git diff
diff --git a/openapi/testdata/petstore/openapi.yaml b/openapi/testdata/petstore/openapi.yaml
index 030f21f..ee08372 100644
--- a/openapi/testdata/petstore/openapi.yaml
+++ b/openapi/testdata/petstore/openapi.yaml
@@ -60,12 +60,7 @@ paths:
tags:
- pets
parameters:
- - name: petId
- in: path
- required: true
- description: The id of the pet to retrieve
- schema:
- type: string
+ - $ref: '#/components/parameters/petId'
responses:
"200":
description: Expected response to a valid request
@@ -109,3 +104,11 @@ components:
format: int32
message:
type: string
+ parameters:
+ petId:
+ in: path
+ required: true
+ description: The id of the pet to retrieve
+ schema:
+ type: string
+
›› go test ./...
ok github.com/danielgtaylor/restish (cached) [no tests to run]
ok github.com/danielgtaylor/restish/cli (cached)
? github.com/danielgtaylor/restish/oauth [no test files]
--- FAIL: TestLoader (0.03s)
--- FAIL: TestLoader/petstore (0.00s)
openapi_test.go:240:
Error Trace: /home/r4um/src/restish/openapi/openapi_test.go:240
Error: Not equal:
expected: cli.API{RestishVersion:"", Short:"Swagger Petstore", Long:"", Operations:[]cli.Operation{cli.Operation{Name:"create-pets", Group:"pets", Aliases:[]string{"createpets"}, Short:"Create a pet", Long:"## Response 201\n\nNull response\n\n## Response default (application/json)\n\nunexpected error\n\n```schema\n{\n code*: (integer format:int32)\n message*: (string)\n}\n```\n", Method:"POST", URITemplate:"http://api.example.com/pets", PathParams:[]*cli.Param(nil), QueryParams:[]*cli.Param(nil), HeaderParams:[]*cli.Param(nil), BodyMediaType:"", Examples:[]string(nil), Hidden:false, Deprecated:""}, cli.Operation{Name:"list-pets", Group:"pets", Aliases:[]string{"listpets"}, Short:"List all pets", Long:"## Response 200 (application/json)\n\nA paged array of pets\n\nHeaders: Next\n\n```schema\n[\n {\n id*: (integer format:int64)\n name*: (string)\n tag: (string)\n }\n]\n```\n\n## Response default (application/json)\n\nunexpected error\n\n```schema\n{\n code*: (integer format:int32)\n message*: (string)\n}\n```\n", Method:"GET", URITemplate:"http://api.example.com/pets", PathParams:[]*cli.Param(nil), QueryParams:[]*cli.Param{(*cli.Param)(0xc0002a8070)}, HeaderParams:[]*cli.Param(nil), BodyMediaType:"", Examples:[]string(nil), Hidden:false, Deprecated:""}, cli.Operation{Name:"show-pet-by-id", Group:"pets", Aliases:[]string{"showpetbyid"}, Short:"Info for a specific pet", Long:"## Response 200 (application/json)\n\nExpected response to a valid request\n\n```schema\n{\n id*: (integer format:int64)\n name*: (string)\n tag: (string)\n}\n```\n\n## Response default (application/json)\n\nunexpected error\n\n```schema\n{\n code*: (integer format:int32)\n message*: (string)\n}\n```\n", Method:"GET", URITemplate:"http://api.example.com/pets/{petId}", PathParams:[]*cli.Param{(*cli.Param)(0xc0002a80e0)}, QueryParams:[]*cli.Param(nil), HeaderParams:[]*cli.Param(nil), BodyMediaType:"", Examples:[]string(nil), Hidden:false, Deprecated:""}}, Auth:[]cli.APIAuth(nil), AutoConfig:cli.AutoConfig{Headers:map[string]string(nil), Prompt:map[string]cli.AutoConfigVar(nil), Auth:cli.APIAuth{Name:"", Params:map[string]string(nil)}}}
actual : cli.API{RestishVersion:"", Short:"Swagger Petstore", Long:"", Operations:[]cli.Operation{cli.Operation{Name:"create-pets", Group:"pets", Aliases:[]string{"createpets"}, Short:"Create a pet", Long:"## Response 201\n\nNull response\n\n## Response default (application/json)\n\nunexpected error\n\n```schema\n{\n code*: (integer format:int32)\n message*: (string)\n}\n```\n", Method:"POST", URITemplate:"http://api.example.com/pets", PathParams:[]*cli.Param(nil), QueryParams:[]*cli.Param(nil), HeaderParams:[]*cli.Param(nil), BodyMediaType:"", Examples:[]string(nil), Hidden:false, Deprecated:""}, cli.Operation{Name:"list-pets", Group:"pets", Aliases:[]string{"listpets"}, Short:"List all pets", Long:"## Response 200 (application/json)\n\nA paged array of pets\n\nHeaders: Next\n\n```schema\n[\n {\n id*: (integer format:int64)\n name*: (string)\n tag: (string)\n }\n]\n```\n\n## Response default (application/json)\n\nunexpected error\n\n```schema\n{\n code*: (integer format:int32)\n message*: (string)\n}\n```\n", Method:"GET", URITemplate:"http://api.example.com/pets", PathParams:[]*cli.Param(nil), QueryParams:[]*cli.Param{(*cli.Param)(0xc0002a8b60)}, HeaderParams:[]*cli.Param(nil), BodyMediaType:"", Examples:[]string(nil), Hidden:false, Deprecated:""}, cli.Operation{Name:"show-pet-by-id", Group:"pets", Aliases:[]string{"showpetbyid"}, Short:"Info for a specific pet", Long:"## Response 200 (application/json)\n\nExpected response to a valid request\n\n```schema\n{\n id*: (integer format:int64)\n name*: (string)\n tag: (string)\n}\n```\n\n## Response default (application/json)\n\nunexpected error\n\n```schema\n{\n code*: (integer format:int32)\n message*: (string)\n}\n```\n", Method:"GET", URITemplate:"http://api.example.com/pets/{petId}", PathParams:[]*cli.Param(nil), QueryParams:[]*cli.Param(nil), HeaderParams:[]*cli.Param(nil), BodyMediaType:"", Examples:[]string(nil), Hidden:false, Deprecated:""}}, Auth:[]cli.APIAuth(nil), AutoConfig:cli.AutoConfig{Headers:map[string]string(nil), Prompt:map[string]cli.AutoConfigVar(nil), Auth:cli.APIAuth{Name:"", Params:map[string]string(nil)}}}
Diff:
--- Expected
+++ Actual
@@ -62,14 +62,3 @@
URITemplate: (string) (len=35) "http://api.example.com/pets/{petId}",
- PathParams: ([]*cli.Param) (len=1) {
- (*cli.Param)({
- Type: (string) (len=6) "string",
- Name: (string) (len=5) "petId",
- DisplayName: (string) "",
- Description: (string) (len=29) "The id of the pet to retrieve",
- Style: (cli.Style) 0,
- Explode: (bool) false,
- Default: (interface {}) <nil>,
- Example: (interface {}) <nil>
- })
- },
+ PathParams: ([]*cli.Param) <nil>,
QueryParams: ([]*cli.Param) <nil>,
Test: TestLoader/petstore
FAIL
FAIL github.com/danielgtaylor/restish/openapi 0.064s
FAIL