Skip to content
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

compatibility for openapi 3.0.0 #33

Open
dpalic opened this issue Nov 20, 2023 · 9 comments
Open

compatibility for openapi 3.0.0 #33

dpalic opened this issue Nov 20, 2023 · 9 comments

Comments

@dpalic
Copy link

dpalic commented Nov 20, 2023

as of checking #31 this project is built on openapi 3.1.0
the swagger generator is as of now and for unclear time not compatible to that version.
It would be great to have a compatibility mode of this wp-openapi to generate 3.0.0 openapi spec, so that many languages are out of the box supported by swagger/openapi generator

do you see any chance to support openapi 3.0.0 e.g. on a branch?

dpalic pushed a commit to dpalic/wp-openapi that referenced this issue Nov 20, 2023
@dpalic
Copy link
Author

dpalic commented Nov 21, 2023

found more issues:

  • the generated openapi definition is writing bool as a type, afaik bool is undefined in the spec and shall be named boolean
               "has_theme_file": {
                  "description": "Theme file exists.",
                  "type": "bool",
                  "context": [
                     "embed",
                     "view",
                     "edit"
                  ],
                  "readonly": true
               },

it is how it looks like from woocommerce generated
/wc/v1/customers/{id}

or

                           "manage_stock": {
                              "type": [
                                 "null",
                                 "object",
                                 "string",
                                 "number",
                                 "boolean",
                                 "integer",
                                 "array"
                              ],
                              "description": "Stock management at variation level."
                           },

which is getting converted into Mixedbut the class is missing after generating

@moon0326
Copy link
Owner

Thanks @dpalic. I can look into 3.0 compatibility, but it will be tricky. As far as I know, WordPress supports/uses the latest JSON schema spec, which is only supported by OpenAPI 3.1.0.

the generated openapi definition is writing bool as a type, afaik bool is undefined in the spec and shall be named boolean

I'll look into it 👍

@dpalic
Copy link
Author

dpalic commented Nov 21, 2023

if it helps I can share you a code generator via PN to identify the issues better

@moon0326
Copy link
Owner

if it helps I can share you a code generator via PN to identify the issues better

That would be great!

@dpalic
Copy link
Author

dpalic commented Nov 28, 2023

Hi,
sorry for delay, plz check this
https://www.dropbox.com/scl/fi/jqiv0pj0v3csrme8dzvij/java-wordpress-reduced.tar.gz?rlkey=q2jfc9jidug3fp4noyqqtkdom&dl=0

this tutorial may help (if new to java and maven):
https://jhipster.xenovation.com/install-sdkman-howto/

and afterwards

sdk list java
sdk install maven 3.8.5

and now

mvn clean package

@moon0326
Copy link
Owner

@dpalic Thanks for the file! I'll try to reproduce the issue soon.

@moon0326
Copy link
Owner

moon0326 commented Dec 8, 2023

Sorry for the delay.

So I think we have two problems.

  1. The current code outputs an invalid type (e.g, bool instead of boolean)
  2. It doesn't support OpenAPI 3.0.

I can fix problem 1, but I think problem 2 is out of scope for this project. We can introduce a layer that attempts to convert the latest JSONSchema (which is supported by the latest WordPress) specification to OpenAPI 3.0, but I'm not sure how well it would work.

I'll work on a fix for #1 for now.

@dpalic
Copy link
Author

dpalic commented Dec 27, 2023

wanted to try #1 but i am missing an release

in the meanwhile (a year ago, swagger integrated support for 3.1.0) so the generator shall do the same. So would have liked to try it
Do you have a new release to try?

dpalic pushed a commit to dpalic/wp-openapi that referenced this issue Dec 27, 2023
@dpalic
Copy link
Author

dpalic commented Jan 5, 2024

@moon0326 do you have any plan to release the latest code as a new release version number?
The latest release is from Beginning of 2023 / 1.0.10
Would be great to have the plugin to try if the fixes, also fix this issue here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants