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

Generate OAS3 as code #174

Merged
merged 1 commit into from
Dec 30, 2024
Merged

Generate OAS3 as code #174

merged 1 commit into from
Dec 30, 2024

Conversation

rgreinho
Copy link
Member

Leverages utoipa to generate the OAS3.

Changes:

  • Splits /ratings and /pipelines.
  • Moves schemas to schema.rs.
  • Adds OAS 3.1 from Axum.
  • Adds OAS 3.0, down-converted from the OAS 3.1.
  • Regenerates the bnaclient.
  • Updates the Justfile.
  • Makes enums not optional.
  • Uses APIErrors struct for errors.
  • Adds ApiError examples for each support HTTP status (400, 401, 403, 404).
  • Adds ErrorResponses enum to group all errors.

Signed-off-by: Rémy Greinhofer [email protected]

@rgreinho rgreinho self-assigned this Dec 28, 2024
@pull-request-size pull-request-size bot added the size/XXL Extra Extra Large (1000+ lines of changes) label Dec 28, 2024
@rgreinho rgreinho force-pushed the utoipa branch 2 times, most recently from f3f96a2 to 4682c3b Compare December 30, 2024 15:41
) -> Result<(StatusCode, Json<Value>), ExecutionError> {
post_ratings_analysis_adaptor(bna_pipeline)
#[utoipa::path(
post,

Choose a reason for hiding this comment

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

should this have a request body for the POST request?

Copy link
Member Author

Choose a reason for hiding this comment

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

It totally should! I completely missed it 😱

Copy link
Member Author

Choose a reason for hiding this comment

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

Fixed ✅

@robahtou
Copy link

noticed that many of the endpoints have: page_size & page. Can these be it's own component schema and use a reference?

@robahtou
Copy link

going over the response errors. Can you make them their own schema? For example,

components:
  responses:
    BadRequest:
      description: The request was formatted incorrectly or missing required parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/APIError'
...

Then,

 /cities:
    get:
      responses:
        '400':
          $ref: '#/components/responses/BadRequest'

something like that?

@rgreinho
Copy link
Member Author

going over the response errors. Can you make them their own schema? For example,

components:
  responses:
    BadRequest:
      description: The request was formatted incorrectly or missing required parameters.
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/APIError'
...

Then,

 /cities:
    get:
      responses:
        '400':
          $ref: '#/components/responses/BadRequest'

something like that?

I think the generator considers them as custom objects and therefore inlines them. This is because I had to created custom examples for each one with the specific error codes and messages.

@rgreinho
Copy link
Member Author

noticed that many of the endpoints have: page_size & page. Can these be it's own component schema and use a reference?

Done ✅

Leverages `utoipa` to generate the OAS3.

Changes:
- Splits `/ratings` and `/pipelines`.
- Moves schemas to schema.rs.
- Adds OAS 3.1 from Axum.
- Adds OAS 3.0, down-converted from the OAS 3.1.
- Regenerates the bnaclient.
- Updates the Justfile.
- Makes enums not optional.
- Uses APIErrors struct for errors.
- Adds ApiError examples for each support HTTP status (400, 401, 403, 404).
- Adds ErrorResponses enum to group all errors.
- Updates Hurl tests.

Signed-off-by: Rémy Greinhofer <[email protected]>
@rgreinho rgreinho merged commit 12c7d41 into main Dec 30, 2024
10 checks passed
@rgreinho rgreinho deleted the utoipa branch December 30, 2024 20:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XXL Extra Extra Large (1000+ lines of changes)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants