Add support for general components and Reference Object [$ref] #132
Replies: 2 comments 1 reply
-
hi @francesco-loreti ! You are welcome. Yes, I am aware that the reusability is a problem in OasRails, repeating some request bodyes or params is hard. And what you propose can be a solution. OasRails already uses this references, I create a hash with all structures and compare if this exists then I just add a reference, other way I create this object as component. Look at here for example: Or just look an OAS generated by the engine, you will see that responses are just references to components. I made it as it as a way to optimize the generation. But what you say can give to the user the power to create this component and then in the tags just reference to it, just an idea, something like this:
Here you have an endpoint generated by OasRails: {
"tags": [
"Projects"
],
"summary": "Update project",
"description": "",
"operationId": "update_projects_id",
"parameters": [
{
"$ref": "#/components/parameters/14338ed80ba33fefb5c2cfff70439c44"
}
],
"requestBody": {
"$ref": "#/components/requestBodies/c4744a4e27286179b4334052f8544d6e"
},
"responses": {
"200": {
"$ref": "#/components/responses/83e8f45b01e2067edd8382566b5da929"
},
"401": {
"$ref": "#/components/responses/e96d6c0614b8a2bb00b5588ebb1d5af9"
},
"403": {
"$ref": "#/components/responses/12f10ee88400dd582b96154794cd256a"
},
"404": {
"$ref": "#/components/responses/46b1928a3a352098eb36fd0dc4641ba5"
},
"422": {
"$ref": "#/components/responses/34e13d972ee8d772a9f822aa6f6ba6a7"
},
"500": {
"$ref": "#/components/responses/73e249b56ec1a5c52803fd18ed513d1b"
}
},
"security": [
{
"bearer": [ ]
}
]
}, So answering your question, this feature is absolutely possible to do, I think it should be a different file from config that should be merged into the OAS. But the problem is that currently I am focused to make OasRails framework-agnostic. If you have time and want to contribute I will be very happy to help you with some guidelines to develop it and then review a PR, otherwise just open an Issue as a feature request describing it and I will take it in a future ;) |
Beta Was this translation helpful? Give feedback.
-
Hello @a-chacon, thank you for your work and suggestions! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
According to OpenAPI 3 specifications, it is possible to declare general components that can be referenced using the
$ref: "#/components/[schemas, parameters]"
command.This is very useful when you have common parameters and data schemas that can simply be recalled as needed.
Is it possible to add this functionality, for example, in the configuration file?
Thanks for your job!!!
For example in YAML:
OR
Beta Was this translation helpful? Give feedback.
All reactions