-
-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
invalid components error when response schema contains additionalProperties #772
Comments
# issue772.yml
openapi: 3.0.0
info:
title: "Service"
version: 0.1.9
paths:
/service:
get:
responses:
"200":
$ref: "#/components/responses/response1"
components:
responses:
response1:
description: response data
content:
application/json:
schema:
$ref: "#/components/schemas/schema1"
schemas:
schema1:
properties:
"":
type: object
additionalProperties:
type: string
type: object go run github.com/getkin/kin-openapi/cmd/validate@latest issue772.yml
# go: downloading github.com/getkin/kin-openapi v0.114.0
# ... No issue. |
Hi @fenollp as in v0.113.0 AdditionalProperties has been added with the additional field so the validation is failing for me after the marshalling. It would be very helpful if u can help in marshalling it properly.
|
|
|
when converted to struct and then marshalled is changed to
|
I am seeing some weirdness too since v0.113.0 that I think is similar to the issue reported here. Specifically, the changes in #728 seems to be triggering the error. For example, this path: yamlpaths:
/owners/{id}:
get:
tags:
- Owners
summary: Retrieve user or team
description: >-
[https://api-docs.render.com/reference/get-owner](https://api-docs.render.com/reference/get-owner)
parameters:
- name: Accept
in: header
schema:
type: string
example: application/json
- name: id
in: path
schema:
type: string
required: true
description: (Required) The ID of the user or team
example: Lorem amet sin
responses:
"200":
description: OK
headers:
Content-Type:
schema:
type: string
example: application/json
content:
application/json:
schema:
type: object
$ref: "#/components/schemas/owner"
example:
id: nisi aute veniam elit
name: labore
email: id adipisicing Excepteur
type: user
components:
schemas:
owner:
title: "Owner"
description: "The owner object represents an authorized user or team. The `type` property indicates if the owner is a user or team."
type: object
properties:
id:
description: The owner ID.
readOnly: true
type: string
name:
description: The name of the owner.
type: string
email:
description: The email of the owner.
type: string
type:
description: The type of the authorized user.
type: string
enum: ["user", "team"] ...fails validation with the error:
And when that doc is parsed, the I am not sure how the |
Hi, sorry I haven't got much time to look into this right now. kin-openapi/openapi3/schema.go Lines 176 to 193 in cb687bf
A couple leads: json+yaml tags may need to be added to the struct. But I believe a better choice is to implement a @anjaliSeven You should be able to resolve your issue by replacing the YAML package you're using with @praneetloke Take a look around Line 81 in e53fe38
|
@fenollp thanks for the tip! It turned out that my API spec was actually incorrect. The |
@fenollp thanks for the suggestion , will try it |
using |
Yes that's the point. Show us the diff and be helpful. |
@fenollp when marshalled with Invopop, one of the fields returns null. I haven't investigated the reason yet, so I haven't shared any examples. I will share them once I complete my investigation. |
@anjaliSeven Heya, okay. Please reopen this once you do :) |
Given a specification with additional properties in the response schema,
returns error "invalid components: schema "schema1": extra sibling fields: [has schema]"
example:
The text was updated successfully, but these errors were encountered: