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

Support OpenAPI for custom APIs #5134

Merged
merged 12 commits into from
Jul 16, 2024
Merged

Support OpenAPI for custom APIs #5134

merged 12 commits into from
Jul 16, 2024

Conversation

esevastyanov
Copy link
Contributor

@esevastyanov esevastyanov commented Jun 24, 2024

Closes #4424

Example of OpenAPI spec

openapi:
  summary: "Hello API"
  request:
    parameters:
      - name: item_id
        in: query
        schema:
          type: integer
      - name: limit
        in: query
        schema:
          type: integer
      - name: api_key
        in: query
        schema:
          type: string
  response:
    schema:
      type: object
      properties:
        id:
          type: integer
        name:
          type: string
        price:
          type: number
          format: float
        in_stock:
          type: boolean

@esevastyanov esevastyanov marked this pull request as ready for review June 24, 2024 14:53
runtime/compilers/rillv1/parse_api.go Outdated Show resolved Hide resolved
runtime/compilers/rillv1/parse_api.go Outdated Show resolved Hide resolved
runtime/compilers/rillv1/parse_api.go Outdated Show resolved Hide resolved
proto/rill/runtime/v1/resources.proto Outdated Show resolved Hide resolved
Comment on lines 170 to 172
baseSpec := &spec.Swagger{
SwaggerProps: spec.SwaggerProps{
Swagger: "2.0",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason for using v2 instead of v3?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Majorly, to align with project swagger specs and also there is no support of v3 in go-openapi/spec
There is go-openapi/spec3 but it is incomplete

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should go for OpenAPI 3 if possible because it has some useful new features and has been out for a very long time. These libraries might be worth looking into:

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Migrated to kin-openapi

runtime/server/api.go Outdated Show resolved Hide resolved
runtime/server/api.go Outdated Show resolved Hide resolved
runtime/server/api.go Outdated Show resolved Hide resolved
Copy link
Contributor

@begelundmuller begelundmuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this PR looks great now, I think we should use OpenAPI v3 though (see my response to the last unresolved comment)

@begelundmuller begelundmuller merged commit c4ce5c3 into main Jul 16, 2024
7 checks passed
@begelundmuller begelundmuller deleted the custom-api-openapi branch July 16, 2024 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feat(runtime): Support OpenAPI for custom APIs
2 participants