metadevpro / openapi3-ts

TS Model & utils for creating and exposing OpenAPI 3.x contracts.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

OpenApiBuilder > Build empty Spec

nwayve opened this issue · comments

https://github.com/metadevpro/openapi3-ts/blob/master/src/dsl/OpenApiBuilder.spec.ts#L7

Although this passes, the OpenApi Object is missing the security and externalDocs properties.

They are defined in the interface, but they are optional in the spec. That why a minimal spec do not need to contain an explicit security nor externalDoc.
On the contrary, you can add them as needed using the addExternalDoc(), f.e.

Agreed, they are optional in the spec and defined in the interface as optional.
The test is "Build empty spec" which doesn't necessarily mean "Build minimal spec" which is why I thought those properties were missing.
Seems like they should be added to this test for an "empty spec" builder, regardless of them being optional. Either that or the properties components, tags, and servers should be removed in that test.

Perhaps the test should be "Builds the minimal spec" that expects the output object to be:

{
    openapi: "3.0.0",
    info: {
        title: "app",
        version: "version"
    },
    paths:  {}
}

Good point! I will refactor the tests to make them simple.