Comments (8)
Oh, I see, yeah, that should not happen. Will circle back to this on the next bug run at the end of the month.
from libopenapi.
Have just run into this myself
from libopenapi.
No problem, a simple fix in a couple of places. I'll work on this shortly.
from libopenapi.
Available in v0.3.1
from libopenapi.
@daveshanley There seems to be a regression of this issue in the v0.7.0
release.
However, I have not checked previous versions to see if this issue regressed prior to the latest release.
I have also not checked if #54 has also re-surfaced, but I assume it is likely.
Happy to help with a fix, if this would be useful. I would need some guidance with the codebase though.
from libopenapi.
@daveshanley There seems to be a regression of this issue in the
v0.7.0
release. However, I have not checked previous versions to see if this issue regressed prior to the latest release.I have also not checked if #54 has also re-surfaced, but I assume it is likely.
Happy to help with a fix, if this would be useful. I would need some guidance with the codebase though.
Hi Joe,
Generally with each bug fix, I add a test to validate and prevent regressions. I may have missed this one, but I haven't heard any other comments from folks about it regressing.
I do remember seeing that code again on my travels recently, but I didn't touch it, at least I can't remember touching it. So what would be helpful is a reproducible sample?
from libopenapi.
@daveshanley There seems to be a regression of this issue in the
v0.7.0
release. However, I have not checked previous versions to see if this issue regressed prior to the latest release.
I have also not checked if #54 has also re-surfaced, but I assume it is likely.
Happy to help with a fix, if this would be useful. I would need some guidance with the codebase though.Hi Joe,
Generally with each bug fix, I add a test to validate and prevent regressions. I may have missed this one, but I haven't heard any other comments from folks about it regressing.
I do remember seeing that code again on my travels recently, but I didn't touch it, at least I can't remember touching it. So what would be helpful is a reproducible sample?
Thanks for your swift response 👍
Under further investigation, the issue seems to only apply to response headers, and request headers are working as expected.
In which case this may be an issue that has not be reported before.
The following is a main.go
file that parses two minimal openapi files, one with x-
prefixed headers, one without.
(I would've provided a playground link, but alas, the library doesn't pull before the execution timeout)
package main
import (
"fmt"
"github.com/pb33f/libopenapi"
)
func main() {
fmt.Println("Spec with x-:")
printHeaders(`openapi: 3.0.0
paths:
/pets:
get:
parameters:
- name: x-api-key
in: header
responses:
'200':
headers:
x-next:
schema:
type: string
content:
application/json:
schema:
type: object
`)
fmt.Println("Spec without x-:")
printHeaders(`openapi: 3.0.0
paths:
/pets:
get:
parameters:
- name: api-key
in: header
responses:
'200':
headers:
next:
schema:
type: string
content:
application/json:
schema:
type: object
`)
}
func printHeaders(spec string) {
document, err := libopenapi.NewDocument([]byte(spec))
if err != nil {
panic(err)
}
v3Model, errs := document.BuildV3Model()
if len(errs) > 0 {
panic(errs)
}
for _, pathItem := range v3Model.Model.Paths.PathItems {
for _, op := range pathItem.GetOperations() {
fmt.Printf("\tRequest headers:\n")
for _, param := range op.Parameters {
if param.In == "header" {
fmt.Printf("\t\t- %s\n", param.Name)
}
}
fmt.Printf("\tResponse headers:\n")
for _, resp := range op.Responses.Codes {
for headerName, _ := range resp.Headers {
fmt.Printf("\t\t- %s\n", headerName)
}
}
}
}
}
As can be seen in the output of this file's execution, request headers where correctly found, but the response headers were
only provided when not prefixed.
$ go run main.go
Spec with x-:
Request headers:
- x-api-key
Response headers:
Spec without x-:
Request headers:
- api-key
Response headers:
- next
Thanks for your time on this.
from libopenapi.
@JoeReid Can you try v0.8.3
Header keys in responses can now use extension prefixes.
from libopenapi.
Related Issues (20)
- Panic During Schema Rendering HOT 3
- Circular reference does not return an error HOT 3
- Bug: securitySchemes oauth2 empty scopes is stripped HOT 2
- [bug] remote specs with local references
- [Question] How to keep `components.schemas` when bundling openapi spec from multiple files? HOT 3
- NewDocument doesn't follow references HOT 1
- In-document references in remote documents not resolving correctly HOT 3
- Race Condition in BuildV3Model
- Panic when rendering a nullable example
- Example not compiling due to error: cannot range over docModel.Model.Paths.PathItems HOT 4
- Bundle Recursive Refs without Resolving
- Quickstart tutorial leads to `nil pointer dereference error` HOT 3
- SpecIndex.GetAll* functions inconsistent - make consistent with GetAllSchemas.
- Add support for OpenAPI v4 Moonwalk HOT 1
- Slowly migrate to range over func HOT 7
- SchemaTypeRef field wrong set nil HOT 1
- Add support for Document Hashing HOT 1
- Server Variables Object is missing extensions HOT 2
- Merging with anchors is not functioning as expected HOT 2
- Support extensions for `info.contact` object in OpenAPI 3.1.0
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from libopenapi.