moon0326 / wp-openapi

18 stars 5 forks source link

compatibility for openapi 3.0.0 #33

Open dpalic opened 11 months ago

dpalic commented 11 months ago

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 commented 11 months ago

found more issues:

               "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 commented 11 months ago

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 commented 11 months ago

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

moon0326 commented 11 months ago

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

That would be great!

dpalic commented 10 months ago

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 commented 10 months ago

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

moon0326 commented 10 months ago

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 commented 9 months ago

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 commented 9 months ago

@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