Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix: Get the name of the board#56

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
shanaya-Gupta wants to merge1 commit intoarduino:main
base:main
Choose a base branch
Loading
fromshanaya-Gupta:fix-55
Draft
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletionsinternal/api/api.go
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -101,3 +101,19 @@

return mux
}


func GetBoardNameHandler() http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
// micro.GetBoardName() will be defined in internal/micro/micro.go as per plan
name := micro.GetBoardName()
response := map[string]string{"name": name}
if err := json.NewEncoder(w).Encode(response); err != nil {
http.Error(w, "Failed to encode response: "+err.Error(), http.StatusInternalServerError)
return
}
}
}

mux.Handle("GET /v1/system/name", GetBoardNameHandler())

Check failure on line 119 in internal/api/api.go

View workflow job for this annotation

GitHub Actions/ go-test-internal

syntax error: non-declaration statement outside function body
21 changes: 21 additions & 0 deletionsinternal/api/docs/openapi.yaml
View file
Open in desktop
Copy link
Contributor

Choose a reason for hiding this comment

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

theopenapi.yaml file is generated fromcmd/gendoc/docs.go file.

You have to add your definition programmatically.

You can take inspiration from:

'data: {"code":"INTERNAL_SERVER_ERROR","message":"An error occurred during operation"}'
`,
},
Description:"Returns the system resources usage, such as memory, disk and CPU.",
Summary:"Get system resources usage",
Tags: []Tag{SystemTag},
PossibleErrors: []ErrorResponse{
{StatusCode:http.StatusInternalServerError,Reference:"#/components/responses/InternalServerError"},
},
},
{
OperationId:"checkUpdate",
Method:http.MethodGet,
Path:"/v1/system/update/check",
Parameters: (*struct {
OnlyArduinobool`query:"only-arduino" description:"If true, check only for Arduino packages that require an upgrade. Default is false."`
})(nil),
CustomSuccessResponse:&CustomResponseDef{
ContentType:"application/json",
DataStructure: handlers.UpdateCheckResult{},
Description:"Successful response",
StatusCode:http.StatusOK,
},
Description:"Returns the details of packages to be upgraded.",
Summary:"Get the packages that requires an upgrade",
Tags: []Tag{SystemTag},
PossibleErrors: []ErrorResponse{
{StatusCode:http.StatusInternalServerError,Reference:"#/components/responses/InternalServerError"},
{StatusCode:http.StatusBadRequest,Reference:"#/components/responses/BadRequest"},
{StatusCode:http.StatusNoContent,Reference:"#/components/responses/NoContent"},
},

Copy link
Contributor

Choose a reason for hiding this comment

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

@lucarin91 perhaps would be better to go back to spec first approach, to ease future contributions?

lucarin91 reacted with confused emoji
Original file line numberDiff line numberDiff line change
Expand Up@@ -1669,3 +1669,24 @@ components:
version:
type: string
type: object


/v1/system/name:
Copy link
Contributor

Choose a reason for hiding this comment

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

It might be better to use a more generic endpoint like /v1/system/information.
This would make the API more cohesive and easier to extend in the future if new properties are added that still fall under the general “information” category.

If you only need to retrieve the system name, you could either include a query parameter filter (e.g. ?filter=name) or use a more specific endpoint such as/v1/system/information/name.

get:
description: Returns the name of the board.
operationId: getBoardName
responses:
"200":
content:
application/json:
schema:
properties:
name:
type: string
type: object
description: Successful response
"500":
$ref: '#/components/responses/InternalServerError'
summary: Get the board's name
tags:
- System
Loading

[8]ページ先頭

©2009-2025 Movatter.jp