Skip to content
This repository has been archived by the owner on Nov 18, 2021. It is now read-only.

encoding/openapi: add support for paths section #386

Closed
proppy opened this issue May 15, 2020 · 1 comment
Closed

encoding/openapi: add support for paths section #386

proppy opened this issue May 15, 2020 · 1 comment
Labels
FeatureRequest New feature or request

Comments

@proppy
Copy link
Contributor

proppy commented May 15, 2020

Is your feature request related to a problem? Please describe.

Currently when doing --out openapi the paths section of the OpenAPI spec would be omitted in the generated output even if a paths value exist in the cue input.

Describe the solution you'd like

It would be nice if paths could be defined along side components.

Describe alternatives you've considered

One alternative could be layer a _path.cue file on top of the generated components.cue, but you have to resolve the components reference yourself.

Additional context

Example:

paths 🍡 cat foo.cue 
info: {
  title: "Foo API"
  version: "v1"
}

#Foo: bar: number

Paths: "/foo":  post: {
  operationId: "foo"
  summary: "foo it"
  responses: "200": content: "application/json": schema: #Foo
}

Currently generate:

{
    "openapi": "3.0.0",
    "info": {
        "title": "Foo API",
        "version": "v1"
    },
    "paths": {},
    "components": {
        "schemas": {
            "Foo": {
                "type": "object",
                "required": [
                    "bar"
                ],
                "properties": {
                    "bar": {
                        "type": "number"
                    }
                }
            }
        }
    }
}

While it would be nice to have something like this instead:

{
    "openapi": "3.0.0",
    "info": {
        "title": "Foo API",
        "version": "v1"
    },
    "paths": {
        "/foo": {
            "post": {
                "operationId": "foo,
                "summary": "foo it",
                "responses": {
                    "200": {
                        "content": {
                            "application/json": {
                                "schema": {
                                    "$ref": "#/components/schemas/#Foo"
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    "components": {
        "schemas": {
            "Foo": {
                "type": "object",
                "required": [
                    "bar"
                ],
                "properties": {
                    "bar": {
                        "type": "number"
                    }
                }
            }
        }
    }
}
@cueckoo
Copy link

cueckoo commented Jul 3, 2021

This issue has been migrated to cue-lang/cue#386.

For more details about CUE's migration to a new home, please see cue-lang/cue#1078.

@cueckoo cueckoo closed this as completed Jul 3, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FeatureRequest New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants