Opened 4 years ago

Last modified 5 months ago

#22034 new enhancement

[PATCH] Improve OpenAPI and remote control output — at Version 3

Reported by: hiddewie Owned by: team
Priority: normal Milestone:
Component: Core Version:
Keywords: openapi swagger Cc: gaben

Description (last modified by hiddewie)

I was using the remote control APIs and found the OpenAPI file lacking in details. Especially the types of parameters were all string which removes validation in the Swagger UI and other OpenAPI tools.

There was a TODO in the code for this.

To solve the issue of parameter typing, I added a RequestParameter class that handles the conversion and parsing from request parameters to the actual parameter value. It also contains the metadata like whether the parameter is required and the OpenAPI type.

Attached is the patch file.

Changes:

  • Add response codes & descriptions to each API
  • OpenAPI version from 3.0.0 to 3.0.3
  • Use the configured port in the OpenAPI server block from the configured property remote.control.port or the default (using IntegerProperty).
  • Add RequestParameter object that describes and parses a mandatory/optional request parameter. This information is used in the OpenAPI specification as well
  • Capitalize descriptions of the request handlers

The class RequestHandler should be backwards compatible for use in plugins.

Ref https://swagger.io/specification/ for OpenAPI specification

Change History (8)

by hiddewie, 4 years ago

Attachment: remote-control.patch added

patch v1

by hiddewie, 4 years ago

Attachment: remote-control.2.patch added

patch v2

comment:1 by stoecker, 4 years ago

First look comments:

  • New functions+classes should have an "@since xxx" so they are properly attributed during checkin
  • Are the uppercase/lowercase text changes really necessary?

comment:2 by hiddewie, 4 years ago

Added the @since on the new class and functions.

I also noticed I forgot to include RequestParameter in the patch (this is pretty difficult compared to a Git branch and a pull request). I added the missing file.

Are the uppercase/lowercase text changes really necessary?

I think they are: descriptions should be verbose pieces of text with full sentences. And those start with a capital letter. It also looks neater when the specification is opened in a Swagger UI (or similar tool).

See attached screenshots of the usage with a Swagger UI.

by hiddewie, 4 years ago

Attachment: remote-control.3.patch added

patch v3

by hiddewie, 4 years ago

Swagger UI (https://editor.swagger.io/ for hosted version)

by hiddewie, 4 years ago

Single operation in swagger UI

comment:3 by hiddewie, 4 years ago

Description: modified (diff)
Note: See TracTickets for help on using tickets.