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

Dependencies updated #17

Merged
merged 4 commits into from
May 9, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
83 changes: 53 additions & 30 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,32 @@
run:
go: '1.19'
timeout: 5m
issues-exit-code: 1
tests: true
skip-dirs-use-default: true
modules-download-mode: readonly
allow-parallel-runners: true

output:
format: tab
print-issued-lines: true
print-linter-name: true
# Print all issue on single line.
# We should set to false 'cause if one single line has issues from different
# linters we will see only one of them.
uniq-by-line: false
sort-results: true

linters-settings:
depguard:
list-type: blacklist
packages:
# logging is allowed only by logutils.Log, logrus
# is allowed to use only in logutils package
- github.com/sirupsen/logrus
packages-with-error-message:
- github.com/sirupsen/logrus: "logging is allowed only by logutils.Log"
rules:
main:
list-mode: lax # allows unless explicitly denied
deny:
- pkg: "github.com/sirupsen/logrus"
desc: logging is allowed only by logutils.Log, logrus is allowed to use only in logutils package
dupl:
threshold: 100
threshold: 150
funlen:
lines: 100
statements: 50
Expand All @@ -27,11 +45,15 @@ linters-settings:
- ifElseChain
- octalLiteral
- whyNoLint
- wrapperFunc
settings:
hugeParam:
sizeThreshold: 210
rangeValCopy:
sizeThreshold: 220
gocyclo:
min-complexity: 15
min-complexity: 30
goimports:
local-prefixes: github.com/golangci/golangci-lint
local-prefixes: github.com/jsightapi/jsight-api-core
gomnd:
# don't include the "operation" and "assign"
checks:
Expand All @@ -46,7 +68,6 @@ linters-settings:
- '3'
ignored-functions:
- strings.SplitN
- strconv.FormatUint

govet:
check-shadowing: true
Expand All @@ -58,11 +79,10 @@ linters-settings:
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Errorf
- (github.com/golangci/golangci-lint/pkg/logutils.Log).Fatalf
lll:
line-length: 140
line-length: 120
misspell:
locale: US
nolintlint:
allow-leading-space: true # don't require machine-readable nolint directives (i.e. with no leading space)
allow-unused: false # report any unused nolint directives
require-explanation: false # don't require an explanation for nolint directives
require-specific: false # don't require nolint directives to be specific about which linter is being skipped
Expand All @@ -83,7 +103,7 @@ linters:
- gocyclo
- gofmt
- goimports
- gomnd
# - gomnd
- goprintffuncname
- gosec
- gosimple
Expand Down Expand Up @@ -123,20 +143,23 @@ issues:
exclude-rules:
- path: _test\.go
linters:
- gomnd
- dupl
- errcheck
- goconst
- gocritic
- gocyclo
- gosec
- ifshort
- lll
- unparam
- funlen

- path: pkg/golinters/errcheck.go
text: "SA1019: errCfg.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/commands/run.go
text: "SA1019: lsc.Errcheck.Exclude is deprecated: use ExcludeFunctions instead"
- path: pkg/commands/run.go
text: "SA1019: e.cfg.Run.Deadline is deprecated: Deadline exists for historical compatibility and should not be used."
# We already have a bunch of code with that name convention, so it's okay for now
# to skip this check.
- source: "(Json|Uuid|Uri|jApi)"
linters:
- stylecheck

run:
timeout: 5m
go: '1.17' # TODO(ldez): we force to use an old version of Go for the CI and the tests.
skip-dirs:
- test/testdata_etc
- internal/cache
- internal/renameio
- internal/robustio
- text: "ST1005: error strings should not be capitalized"
linters:
- stylecheck
24 changes: 14 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,23 +38,25 @@ API](#scroll--jsight-api-language).

Supported standards: [HTTP REST](#scroll--jsight-api-language), [JSON-RPC 2.0](#json-rpc-20-new-feature).

Currently, the **JSight Server API** allows you to perform only one task:
The **JSight Server API** allows you to perform the following tasks:

1. Parsing code in the JSight API language, which results in a JSON structure containing all
information about this API in the *JDoc Exchange Format*.
1. Parsing code in the JSight API language, checking JSight API syntax.
2. Generating a JSON structure containing all information about this API in the *JDoc Exchange
Format* (required for [JSight Online Editor
frontend](https://github.com/jsightapi/online-editor-frontend)).
3. Converting JSight API to OpenAPI (YAML or JSON).

The following features are also planned in the near future:

1. Support for other types of API: gRPC, Kafka, RabbitMQ, WebSocket.
2. Converting from JSight API to OpenAPI.
3. Converting from OpenAPI to JSight API.
4. API documentation generation in MarkDown format.
5. API documentation generation in PDF format.
6. Generation of API server code stubs for different programming languages ​​(Java, PHP, Go,
2. Converting from OpenAPI to JSight API.
3. API documentation generation in MarkDown format.
4. API documentation generation in PDF format.
5. Generation of API server code stubs for different programming languages ​​(Java, PHP, Go,
Node.js, Python, C++ etc.).
7. Generation of API clients for different programming languages ​​(JavaScript, Java, PHP, Go,
6. Generation of API clients for different programming languages ​​(JavaScript, Java, PHP, Go,
Python, C++ etc.).
8. And many other features.
7. And many other features.

> :fire: If you have any ideas or suggestions, please share with us:
>
Expand Down Expand Up @@ -1804,6 +1806,8 @@ document.
<a href="https://github.com/constantine-malyshev"><img src="https://avatars.githubusercontent.com/u/101567029?v=4" width="100" height="100" alt=""/></a>
<a href="https://github.com/dshemin"><img src="https://avatars.githubusercontent.com/u/11780307?v=4" width="100" height="100" alt=""/></a>
<a href="https://github.com/bakhtinphil"><img src="https://avatars.githubusercontent.com/u/104030166?v=4" width="100" height="100" alt=""/></a>
<a href="https://github.com/tobiashochguertel"><img src="https://avatars.githubusercontent.com/u/3332669?v=4" width="100" height="100" alt=""/></a>
<a href="https://github.com/chepil"><img src="https://avatars.githubusercontent.com/u/1425370?v=4" width="100" height="100" alt=""/></a>

<div>
&nbsp;
Expand Down
3 changes: 2 additions & 1 deletion convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ import (
"log"
"net/http"

"github.com/jsightapi/jsight-api-core/kit"
"github.com/jsightapi/jsight-schema-core/fs"

"github.com/jsightapi/jsight-api-core/kit"
)

func convertJSight(w http.ResponseWriter, r *http.Request) {
Expand Down
2 changes: 1 addition & 1 deletion cors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func Test_cors(t *testing.T) {
assert.Len(t, r.Header(), 3)
assert.Equal(t, "*", r.Header().Get("Access-Control-Allow-Origin"))
assert.Equal(t, "POST, GET, OPTIONS, PUT, DELETE", r.Header().Get("Access-Control-Allow-Methods"))
assert.Equal(t, "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, X-Browser-UUID", r.Header().Get("Access-Control-Allow-Headers")) //nolint:lll
assert.Equal(t, "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, X-Browser-UUID", r.Header().Get("Access-Control-Allow-Headers"))
})

t.Run("negative", func(t *testing.T) {
Expand Down
1 change: 1 addition & 0 deletions datagram.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"strconv"

"github.com/jsightapi/datagram"

"github.com/jsightapi/jsight-api-core/jerr"
"github.com/jsightapi/jsight-api-core/kit"
)
Expand Down
3 changes: 2 additions & 1 deletion error_info_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import (
"errors"
"testing"

"github.com/jsightapi/jsight-api-core/jerr"
"github.com/jsightapi/jsight-schema-core/fs"
"github.com/stretchr/testify/assert"

"github.com/jsightapi/jsight-api-core/jerr"
)

func Test_newErrorInfo(t *testing.T) {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ go 1.19
require (
github.com/itchyny/json2yaml v0.1.4
github.com/jsightapi/datagram v0.0.0-20220623160954-98dd8ec27707
github.com/jsightapi/jsight-api-core v0.1.2-0.20240423113206-0c0c42e27be2
github.com/jsightapi/jsight-schema-core v0.1.2-0.20240423075246-00134095f703
github.com/jsightapi/jsight-api-core v0.2.0
github.com/jsightapi/jsight-schema-core v0.2.0
github.com/stretchr/testify v1.9.0
)

Expand Down
8 changes: 4 additions & 4 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ github.com/itchyny/json2yaml v0.1.4 h1:/pErVOXGG5iTyXHi/QKR4y3uzhLjGTEmmJIy97YT+
github.com/itchyny/json2yaml v0.1.4/go.mod h1:6iudhBZdarpjLFRNj+clWLAkGft+9uCcjAZYXUH9eGI=
github.com/jsightapi/datagram v0.0.0-20220623160954-98dd8ec27707 h1:DvpMxaeajafsBn3NVjcaloatbqupVaIdcV4y8KHunI8=
github.com/jsightapi/datagram v0.0.0-20220623160954-98dd8ec27707/go.mod h1:pBj2DBaAOdg5nWXc09jm6IUQnaE4iKMY1tvsx3RmchY=
github.com/jsightapi/jsight-api-core v0.1.2-0.20240423113206-0c0c42e27be2 h1:Bkdj/vK/gUn9yno19msQd1WgpLUGX6AV6eGuqZeWinU=
github.com/jsightapi/jsight-api-core v0.1.2-0.20240423113206-0c0c42e27be2/go.mod h1:E40rcUKurTxeMiGUfBJuvLy552u5gqAPVL4oMnw7JA8=
github.com/jsightapi/jsight-schema-core v0.1.2-0.20240423075246-00134095f703 h1:74zV9j7gorOkgocDkYSfBMzOhW0VbkCo0oVgJ2rh4LM=
github.com/jsightapi/jsight-schema-core v0.1.2-0.20240423075246-00134095f703/go.mod h1:LARaGZOYbAnCd3Azckksdmb0gm8vUzJ94Kvg/JNOf1k=
github.com/jsightapi/jsight-api-core v0.2.0 h1:0j1ybriM72VQnDxcfoa8kHi83BdpuWlLfktRByfGBc4=
github.com/jsightapi/jsight-api-core v0.2.0/go.mod h1:zhKY676odlUDvYF+qyxtV3l29z/WrEYAK/Hp4E/oGP4=
github.com/jsightapi/jsight-schema-core v0.2.0 h1:3dZHAzuVlrhO1bU/96KIfQuLNItg1p98NBK8kegcD50=
github.com/jsightapi/jsight-schema-core v0.2.0/go.mod h1:LARaGZOYbAnCd3Azckksdmb0gm8vUzJ94Kvg/JNOf1k=
github.com/lucasjones/reggen v0.0.0-20200904144131-37ba4fa293bb h1:w1g9wNDIE/pHSTmAaUhv4TZQuPBS6GV3mMz5hkgziIU=
github.com/lucasjones/reggen v0.0.0-20200904144131-37ba4fa293bb/go.mod h1:5ELEyG+X8f+meRWHuqUOewBOhvHkl7M76pdGEansxW4=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
4 changes: 2 additions & 2 deletions http_response_writer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ func Test_httpResponseJDoc200(t *testing.T) {
})
}

func Test_httpResponseJSON200(t *testing.T) { //nolint:dupl
func Test_httpResponseJSON200(t *testing.T) {
t.Run("positive", func(t *testing.T) {
t.Run("with content", func(t *testing.T) {
const content = "foobar"
Expand Down Expand Up @@ -85,7 +85,7 @@ func Test_httpResponseJSON200(t *testing.T) { //nolint:dupl
})
}

func Test_httpResponseYAML200(t *testing.T) { //nolint:dupl
func Test_httpResponseYAML200(t *testing.T) {
t.Run("positive", func(t *testing.T) {
t.Run("with content", func(t *testing.T) {
const content = "foobar"
Expand Down
6 changes: 3 additions & 3 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ TYPE @cat
},
func(t *testing.T, r *httptest.ResponseRecorder) {
assert.Equal(t, http.StatusOK, r.Code)
assert.Equal(t, `{"tags":{},"userTypes":{"@cat":{"schema":{"content":{"tokenType":"object","type":"object","children":[{"key":"id","tokenType":"number","type":"integer","scalarValue":"1","optional":false}],"optional":false},"example":"{\"id\":1}","notation":"jsight"}}},"interactions":{},"jsight":"0.3","jdocExchangeVersion":"2.0.0"}`, r.Body.String()) //nolint:lll
assert.Equal(t, `{"tags":{},"userTypes":{"@cat":{"schema":{"content":{"tokenType":"object","type":"object","children":[{"key":"id","tokenType":"number","type":"integer","scalarValue":"1","optional":false}],"optional":false},"example":"{\"id\":1}","notation":"jsight"}}},"interactions":{},"jsight":"0.3","jdocExchangeVersion":"2.0.0"}`, r.Body.String())
},
},

Expand All @@ -68,7 +68,7 @@ TYPE @cat
},
func(t *testing.T, r *httptest.ResponseRecorder) {
assert.Equal(t, http.StatusConflict, r.Code)
assert.Equal(t, `{"Status":"Error","Message":"invalid character 'i' at directive beginning","Line":1,"Index":0}`, r.Body.String()) //nolint:lll
assert.Equal(t, `{"Status":"Error","Message":"invalid character 'i' at the directive beginning","Line":1,"Index":0}`, r.Body.String())
},
},
}
Expand Down Expand Up @@ -190,7 +190,7 @@ func assertAll(t *testing.T, cc map[string]testCase) {
c.asserter(t, r)
assert.Equal(t, "*", r.Header().Get("Access-Control-Allow-Origin"))
assert.Equal(t, "POST, GET, OPTIONS, PUT, DELETE", r.Header().Get("Access-Control-Allow-Methods"))
assert.Equal(t, "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, X-Browser-UUID", r.Header().Get("Access-Control-Allow-Headers")) //nolint:lll
assert.Equal(t, "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization, X-Browser-UUID", r.Header().Get("Access-Control-Allow-Headers"))
})
}
}
1 change: 1 addition & 0 deletions openapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (
"encoding/json"

"github.com/itchyny/json2yaml"

"github.com/jsightapi/jsight-api-core/catalog/ser/openapi"
"github.com/jsightapi/jsight-api-core/kit"
)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions vendor/github.com/jsightapi/jsight-api-core/jerr/const.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading