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

OpenAPI to/from Flow Schema #1353

Open
norberttech opened this issue Jan 11, 2025 · 0 comments
Open

OpenAPI to/from Flow Schema #1353

norberttech opened this issue Jan 11, 2025 · 0 comments
Milestone

Comments

@norberttech
Copy link
Member

One of the things that will help to consume/expose Http-based datasets would be to be able to infer/generate OpenAPI specification for a given dataset.

Here is an example scenario, let's say we want to expose a dataset through the API (instead of granting read-only access to our filesystem/db).

Let say this is our schema:

$schema = schema(
    int_schema('id', $nullable = false),
    str_schema('name', $nullable = true),
    bool_schema('active', $nullable = false, Metadata::empty()->add('key', 'value')),
);

Lets build a OpenAPI specification for that endpoint:

openapi: 3.0.0
info:
  title: User API
  version: 1.0.0
paths:
  /users:
    get:
      summary: Get list of users
      responses:
        '200':
          description: A list of users
          content:
            application/json:
              schema:
                type: array
                items:
                  type: object
                  properties:
                    id:
                      type: integer
                      nullable: false
                      example: 1
                    name:
                      type: string
                      nullable: true
                      example: "John Doe"
                    active:
                      type: boolean
                      nullable: false
                      example: true
components:
  schemas:
    User:
      type: object
      properties:
        id:
          type: integer
          nullable: false
        name:
          type: string
          nullable: true
        active:
          type: boolean
          nullable: false

If we take a closer look properties are 1:1 translatable to/from Flow Schema.

We can add it as a new Bridge src/bridge/openapi/flow/ that would provide two converters:

  • Flow to OpenAPI
  • OpenAPI to Flow
@norberttech norberttech moved this to Todo in Roadmap Jan 11, 2025
@norberttech norberttech added this to the 0.11.0 milestone Jan 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Todo
Development

No branches or pull requests

1 participant