-
Notifications
You must be signed in to change notification settings - Fork 939
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
Warning Skipping unknown & Required @OA\Info() not found in zircote/swagger-php/src/Loggers/DefaultLogger.php #1695
Comments
Depends to a degree on the versions - was this an upgrade from v3 -> v4 or v4 -> v5? It would definitley help to get the current (non working) version and perhaps some reproducer code (ideally simplified to a single file) |
I recently ran a composer upgrade to update Swagger, but I’m unsure which version I upgraded from. Currently, the production server is still running the old version, while my localhost has been upgraded to the latest version. If needed, I can provide additional details, but I would appreciate your guidance on how to proceed. |
I’m currently facing the same issue after upgrading, and I’ve had to leave it non-functional for now. could you also advise on how to ensure a smooth transition for the production server when upgrading? |
I would love to help, but I seriously need more details or a reproducer.
|
Thank you for your question. Yes, I am using annotations instead of attributes. Again, I was previously using an older version of Swagger, which was functioning well with the same structure. For your reference, I’ve attached two files: The first file generates the JSON content.
If you need the old version for comparison or to align it with the new one, please let me know the steps required to retrieve it. I’ll be happy to obtain the necessary details from the production server. Note that I was running on version 3 as per the below:
and now upgraded to
Regards |
I followed the guide at https://zircote.github.io/swagger-php/guide/faq.html#annotations-missing with the same issue too. Was working and stopped upon upgrade. |
Same here, no longer working after upgrading from 3 to 5 |
Experiencing the same issue after upgrading from version 3 to 5. It was working perfectly before the update. |
I think you are all facing this issue: https://zircote.github.io/swagger-php/guide/faq#warning-required-oa-info-not-found As of v4 swagger-php uses reflection. In order for reflection to be able to find code, that code needs either to be loaded upfront (good old Taking @rabihmb's sample code I had to make the following changes:
The key is that swagger-php is not |
As mentioned previously, I followed the steps outlined and created a new class from scratch. The steps were basic and straightforward, but I’m still encountering the same issue. It appears the process is stuck on the same error. could you kindly review the implementation and provide guidance on how to resolve this? I shared the code for additional details and further analysis.
|
Ok, first of all there are a couple minor issues with your annotations:
So, here is the corrected file ( <?php
////////////////////////////////////////////////////////////////////////////////
use OpenApi\Annotations as OA;
//////////////////////////////////////////////////////////////////////////////
/**
* @OA\Tag(
* name="user",
* description="User related operations"
* )
* @OA\Info(
* title="Data API Document",
* version="1.0.7",
* description="All endpoints related to this website",
* @OA\License(name="Apache 2.0",url="http://www.apache.org/licenses/LICENSE-2.0.html"),
* @OA\Contact(email="[email protected]"),
* @OA\Attachable()
* )
* @OA\PathItem(path="/api")
* @OA\Server(
* url="https://mysite.com/api/",
* description="mysite Secured API"
* )
* @OA\SecurityScheme(
* type="http",
* description="Use the generated bearer code to get the token",
* scheme="bearer",
* bearerFormat="JWT",
* securityScheme="bearerAuth"
* )
*/
class OpenApiSpec
{
} Secondly, you have two choices to generate the spec from the file.
./vendor/bin/openapi -b src/other.php src/other.php
<?php
////////////////////////////////////////////////////////////////////////////////
require("../../vendor/autoload.php");
require 'src/other.php';
$openapi = \OpenApi\Generator::scan(["./src/other.php"]);
header("Content-Type: application/json; charset=UTF-8");
echo $openapi->toJson();
//header("Content-Type: application/x-yaml");
//echo $openapi->toYaml(); |
Thank you very much for your advice. The below code were solved the problem
Is there any autoload to load the entire my src/ files recursively? |
Yep. It's called composer: https://getcomposer.org/doc/00-intro.md |
No I mean to auto load the api files that We made. I have v1 and v2 and both are used so we need to load them dynamically instead of add require each file one by one. |
Yes, I understand and that is why I said composer :) |
But currently isn't not :) When I didn't require the v1 files it gave the same old issue, but when I add them one by one using require it works. |
Well, this is outside of the scope of this project. I do recommend reading the composer docs, in particular about autoloading: https://getcomposer.org/doc/01-basic-usage.md#autoloading |
my name on here is a little unfortunate. code blocks prevent tagging me btw 😄 |
I was previously using an older version of Swagger, which was functioning well. Recently, I upgraded to the latest version, for both:
and
The JSON file was successfully loaded and is displaying correctly in the Swagger UI, However, I’m encountering an issue that I’ve been unable to resolve despite trying multiple solutions. Before reaching out, I attempted various troubleshooting steps, but none were successful. Getting now warning displayed below
Could you kindly let me know if there are any specific steps or configurations I should follow to ensure everything works seamlessly after the upgrade? taking into consideration that the json file was loaded and showing in the swagger ui well
The text was updated successfully, but these errors were encountered: