docusaurus-openapi icon indicating copy to clipboard operation
docusaurus-openapi copied to clipboard

Is there support for OpenAPI 3.1.0?

Open KinjalWS opened this issue 3 years ago • 4 comments

I was very much fascinated by the UI flexibility and the features docusaurus-openapi provide. But I'm a bit skeptical about the support for OpenAPI 3.1.0. Is it supported yet?

KinjalWS avatar May 20 '22 04:05 KinjalWS

Have you tried testing with 3.1.0?

bourdakos1 avatar May 20 '22 05:05 bourdakos1

I tried with 3.1.0. Actually OpenAPI 3.1.0 supports multiple types in a schema (also specified here: Specifying multiple types for additionalProperties through Swagger/OpenAPI)

I tried debugging as follows: node_modules/docusaurus-plugin-openapi/lib/openapi/createExample.js

function primitive(schema = {}) {
    let { type, format } = schema;
    if (type === undefined || type === null) {
        return;
    }
    console.log(type);
    let fn = primitives[type].default;
    if (format !== undefined) {
        fn = primitives[type][format] || fn;
    }
    if (fn) {
        return fn(schema);
    }
    return "Unknown Type: " + schema.type;
}

I logged the output to find that last type was an array and it the primitive function doesn't handle arrays well! Here's the output:

image

KinjalWS avatar May 20 '22 05:05 KinjalWS

Then I guess we don’t support 3.1.0

bourdakos1 avatar May 20 '22 05:05 bourdakos1

Okay cool! I'll then go back to OpenAPI 3.0.3 as of now!

Should I close this issue?

Thanks and Regards, Kinjal Raykarmakar

KinjalWS avatar May 20 '22 06:05 KinjalWS