-
-
Notifications
You must be signed in to change notification settings - Fork 532
parameters
defined directly under a path no longer gets merged to parameters defined under a specific operation for that path
#1065
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
Comments
A bug was fixed in the last few days that should have addressed this. Can you confirm this is in the latest version ( |
This is in 6.2.1 yes! |
OK. Then it’s probably a minor, fixable oversight. #1061 fixed several longstanding issues with parameters that had existed in all previous versions. So this specific bug should be able to be fixed without too much fuss. |
Ah I think your schema is invalid—it should be: {
"in": "path",
"name": "thread_id",
"required": true,
- "type": "string"
+ "schema": { "type": "string" }
} Sidenote: that’s why the I noticed a few other validation errors in your schema, but I believe this one could be causing the issue. After all the validation errors are fixed, please let me know if it’s still generating unexpected output |
Sorry about that! I can't share the actual spec publicly, so I made an attempt at simplifying it - but clearly poorly. The original spec is definitely valid. Here's an updated example that actually is valid: {
"openapi": "3.0.2",
"info": {
"title": "Foo",
"version": "1.0.0"
},
"servers": [],
"paths": {
"/v1/auth/comments/{thread_id}": {
"get": {
"operationId": "get_comment_resource",
"parameters": [
{
"in": "query",
"name": "page_size",
"required": false,
"schema": {
"default": 20,
"maximum": 100,
"minimum": 1,
"type": "integer"
}
},
{
"in": "query",
"name": "start",
"required": false,
"schema": {
"nullable": true,
"type": "string"
}
}
],
"responses": {
"200": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/PaginatedResponseCommentDumpSchema"
}
}
},
"description": "Success"
}
},
"security": [],
"summary": "Returns comments associated with a given thread",
"tags": ["Comments"]
},
"parameters": [
{
"in": "path",
"name": "thread_id",
"required": true,
"schema": {
"format": "uuid",
"type": "string"
},
"style": "simple"
}
],
"post": {
"operationId": "post_comment_resource",
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/CreateComment"
}
}
},
"required": true
},
"responses": {
"201": {
"description": "Success"
}
},
"security": [],
"summary": "Create a comment and add to thread",
"tags": ["Comments"]
}
}
},
"components": {
"schemas": {
"PaginatedResponseCommentDumpSchema": {
"properties": {
"total_count": {
"type": "integer"
}
},
"type": "object"
},
"CreateComment": {
"properties": {
"body": {},
"mentions": {
"items": {
"type": "string"
},
"type": "array"
},
"message": {
"default": "",
"type": "string"
}
},
"type": "object"
}
}
}
} |
Minimal reproduction: paths:
/bar:
get: {}
post: {}
parameters:
- name: my_param
in: query
schema:
type: string generates: export interface paths {
"/bar": {
get: {
};
post: {
};
parameters?: {
query?: {
my_param?: string;
};
};
};
} Honestly, I'm pretty confused. We have a test for this: https://github.com/drwpow/openapi-typescript/blob/main/test/paths-object.test.ts#L24-L95 which passes, but if I take that exact schema and try it locally I see the behavior described in this issue. |
Ahh I see now! @olivierbeaulieu thanks for providing a complete example. Yes this is an issue with how the operations get hoisted up and merged together—there is a bug in that bit of magic. But shouldn’t be too hard to fix! |
Description
When
parameters
are defined for all operations under a path (common usage is for path params), as of v6 they are no longer added to the parameters of every operation under it.In the examples below, notice how
thread_id
use to be added to the definition ofget_comment_resource
andpost_comment_resource
. Under v6, that is no longer the case.OpenAPI
Generated TS
*Expected TS, output from v5.4.1
Checklist
The text was updated successfully, but these errors were encountered: