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

Found Bug in OpenAPI Docs - not correctly reflecting Models 🐛 #367

Open
wetisobe opened this issue Oct 25, 2024 · 0 comments
Open

Found Bug in OpenAPI Docs - not correctly reflecting Models 🐛 #367

wetisobe opened this issue Oct 25, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@wetisobe
Copy link

Describe the bug 🐛
The file openapi.json does not reflect endpoints correctly, it does not parse input objects correctly. When accepting a custom model as input to a post request, it is not reflected correctly to the openapi.json and the endpoint /docs/swagger.

To Reproduce 👨‍🔬
This is a minimal example:

import happyx

# Here are the enums
type
    options_encoding* = enum
        encodingA, encodingB

# here is some model 
model DataProcessRequest: 
    data: string = ""
    storage: options_encoding = encodingA
    xtemplate: string = "" 

# Serve at http://127.0.0.1:5000
serve "0.0.0.0", 5000:

  # on GET HTTP method at http://127.0.0.1:5000/
  get "/":
    {.gcsafe.}:
      return %*{
        "response": "success",
        "msg": "These are not the droids, you're looking for."
      }

  post "/api/process[r:DataProcessRequest:json]":
    {.gcsafe.}:
      # Return plain text

      # process data here

      return %*{
        "response": "success"
      }
      

The OpenAPI results in this:

{"openapi":"3.1.0","swagger":"2.0","info":{"title":"HappyX OpenAPI Docs","version":"1.0.0"},"paths":{"/":{"get":{"description":"","parameters":[],"requestBody":{},"responses":{}}},"/api/process":{"post":{"description":"","parameters":[],"requestBody":{},"responses":{}}}},"components":{"schemas":{"DataProcessRequest":{"type":"object","properties":{"data":{"type":"string"},"xtemplate":{"type":"string"}}}},"parameters":{},"responses":{},"securitySchemas":{},"headers":{},"links":{},"callbacks":{},"pathItems":{},"examples":{},"requestBodies":{},"/":{},"/api/process":{}}}

As you can see the Object is missing the enum, also it is not reflected to the frontend (see screenshot).
(Also the correct return codes are missing as this can only return a 200, but this is a minor thing in this case)

Expected behavior 🤔
I expect the two endpoints to be visible and correctly typed in the openapi.json.

Screenshots 🖼
grafik

Please complete the following information 📃

  • OS: Ubuntu
  • OS Version 22.04
  • HappyX version 4.6.2
  • HappyX project type [ssr/spa]
  • HappyX project language Nim
  • Nim version 2.0.4
  • HTTP Server Default
@wetisobe wetisobe added the bug Something isn't working label Oct 25, 2024
@Ethosa Ethosa self-assigned this Oct 26, 2024
Ethosa added a commit that referenced this issue Oct 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants