-
-
Notifications
You must be signed in to change notification settings - Fork 35
Add REST API v2 foundation #1245
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
837a8e7
Add `api` module
nscuro cfddf4c
Run OpenAPI lint workflow for all PRs that modify the spec
nscuro c26591f
Validate all test responses against OpenAPI spec
nscuro 5b0a081
Add spectral checks for response body schemas
nscuro 0df7c10
Suppress unknown keyword warnings during OpenAPI validation
nscuro c92c43d
Merge branch 'main' of github.com:DependencyTrack/hyades-apiserver in…
nscuro f098ff0
Ensure Jackson exceptions are mapped properly
nscuro ec3b757
Add endpoints API v2 (#1310)
sahibamittal 850dd87
Fix checkstyle issues; Tidy up OpenAPI spec
nscuro 52cb0d4
Fix invalid schema ref
nscuro 9b177aa
Merge branch 'main' of github.com:DependencyTrack/hyades-apiserver in…
nscuro cf76d9e
Merge branch 'main' of github.com:DependencyTrack/hyades-apiserver in…
nscuro 999eeff
Adjust tests for change in portfolio metrics calculation
nscuro 8e3e725
Simplify teams and team-memberships resources
nscuro File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| # This file is part of Dependency-Track. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # Copyright (c) OWASP Foundation. All Rights Reserved. | ||
| name: OpenAPI | ||
|
|
||
| on: | ||
| pull_request: | ||
| paths: | ||
| - api/src/main/openapi/** | ||
| - api/src/main/spectral/** | ||
|
|
||
| concurrency: | ||
| group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
| cancel-in-progress: true | ||
|
|
||
| permissions: { } | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| checks: write | ||
| timeout-minutes: 5 | ||
| steps: | ||
| - name: Checkout Repository | ||
| uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2 | ||
| - name: Lint OpenAPI Spec | ||
| uses: stoplightio/spectral-action@577bade2d6e0eeb50528c94182a5588bf961ae8f # tag=v0.8.12 | ||
| with: | ||
| spectral_ruleset: "api/src/main/spectral/ruleset.yaml" | ||
| file_glob: "api/src/main/openapi/openapi.yaml" | ||
|
|
||
| # TODO: Uncomment after the OpenAPI Spec is present in main. | ||
| # breaking-changes: | ||
| # name: Breaking Changes | ||
| # runs-on: ubuntu-latest | ||
| # timeout-minutes: 5 | ||
| # steps: | ||
| # - name: Checkout Repository | ||
| # uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # tag=v4.2.2 | ||
| # with: | ||
| # fetch-depth: 0 | ||
| # - name: Prepare OpenAPI Spec Comparison | ||
| # run: |- | ||
| # cd api/src/main/resources/org/dependencytrack/api/v2 | ||
| # mv openapi.yaml openapi-after.yaml | ||
| # | ||
| # git checkout ${{ github.event.pull_request.base.sha }} -- openapi.yaml | ||
| # mv openapi.yaml openapi-before.yaml | ||
| # - name: Detect Breaking Changes in OpenAPI Spec | ||
| # run: |- | ||
| # docker run -i --rm \ | ||
| # -v "$(pwd)/api/src/main/resources/org/dependencytrack/api/v2:/work:ro" \ | ||
| # pb33f/openapi-changes summary --no-color --no-logo \ | ||
| # openapi-before.yaml openapi-after.yaml |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # api | ||
|
|
||
| Definition of Dependency-Track's REST API, in [OpenAPI v3.0] format. | ||
|
|
||
| The API draws inspiration from [Zalando's RESTful API Guidelines]. | ||
|
|
||
| Conformance to API guidelines is enforced with [spectral] in CI. | ||
| Validation may be performed locally using [`openapi-lint.sh`](../dev/scripts/openapi-lint.sh). | ||
|
|
||
| Interfaces and model classes are generated as part of the build using [openapi-generator]. | ||
|
|
||
| [OpenAPI v3.0]: https://spec.openapis.org/oas/v3.0.3.html | ||
| [Zalando's RESTful API Guidelines]: https://opensource.zalando.com/restful-api-guidelines/ | ||
| [openapi-generator]: https://github.com/OpenAPITools/openapi-generator | ||
| [spectral]: https://github.com/stoplightio/spectral |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,113 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <!-- | ||
| ~ This file is part of Dependency-Track. | ||
| ~ | ||
| ~ Licensed under the Apache License, Version 2.0 (the "License"); | ||
| ~ you may not use this file except in compliance with the License. | ||
| ~ You may obtain a copy of the License at | ||
| ~ | ||
| ~ http://www.apache.org/licenses/LICENSE-2.0 | ||
| ~ | ||
| ~ Unless required by applicable law or agreed to in writing, software | ||
| ~ distributed under the License is distributed on an "AS IS" BASIS, | ||
| ~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| ~ See the License for the specific language governing permissions and | ||
| ~ limitations under the License. | ||
| ~ | ||
| ~ SPDX-License-Identifier: Apache-2.0 | ||
| ~ Copyright (c) OWASP Foundation. All Rights Reserved. | ||
| --> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" | ||
| xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>org.dependencytrack</groupId> | ||
| <artifactId>dependency-track-parent</artifactId> | ||
| <version>5.6.0-SNAPSHOT</version> | ||
| </parent> | ||
|
|
||
| <artifactId>api</artifactId> | ||
| <packaging>jar</packaging> | ||
|
|
||
| <properties> | ||
| <project.parentBaseDir>${project.basedir}/..</project.parentBaseDir> | ||
| <checkstyle.skip>true</checkstyle.skip> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-annotations</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>com.fasterxml.jackson.core</groupId> | ||
| <artifactId>jackson-databind</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>jakarta.annotation</groupId> | ||
| <artifactId>jakarta.annotation-api</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>jakarta.validation</groupId> | ||
| <artifactId>jakarta.validation-api</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>jakarta.ws.rs</groupId> | ||
| <artifactId>jakarta.ws.rs-api</artifactId> | ||
| <scope>provided</scope> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.openapitools</groupId> | ||
| <artifactId>openapi-generator-maven-plugin</artifactId> | ||
| <version>7.13.0</version> | ||
| <executions> | ||
| <execution> | ||
| <id>generate-api-v2</id> | ||
| <phase>generate-sources</phase> | ||
| <goals> | ||
| <goal>generate</goal> | ||
| </goals> | ||
| <configuration> | ||
| <addCompileSourceRoot>true</addCompileSourceRoot> | ||
| <inputSpec>${basedir}/src/main/openapi/openapi.yaml</inputSpec> | ||
| <collapsedSpec>${project.build.directory}/classes/org/dependencytrack/api/v2/openapi</collapsedSpec> | ||
| <generatorName>jaxrs-spec</generatorName> | ||
| <generateApiTests>false</generateApiTests> | ||
| <generateSupportingFiles>false</generateSupportingFiles> | ||
| <generateModelTests>false</generateModelTests> | ||
| <enablePostProcessFile>true</enablePostProcessFile> | ||
| <openapiNormalizer>REF_AS_PARENT_IN_ALLOF=true</openapiNormalizer> | ||
| <configOptions> | ||
| <apiPackage>org.dependencytrack.api.v2</apiPackage> | ||
| <modelPackage>org.dependencytrack.api.v2.model</modelPackage> | ||
| <interfaceOnly>true</interfaceOnly> | ||
| <returnResponse>true</returnResponse> | ||
| <useJakartaEe>true</useJakartaEe> | ||
| <useTags>true</useTags> | ||
| <dateLibrary>java8</dateLibrary> | ||
| <useSwaggerAnnotations>false</useSwaggerAnnotations> | ||
| <generateBuilders>true</generateBuilders> | ||
| <generatePom>false</generatePom> | ||
| <sourceFolder>.</sourceFolder> | ||
| <additionalModelTypeAnnotations> | ||
| @com.fasterxml.jackson.annotation.JsonInclude(com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL) | ||
| </additionalModelTypeAnnotations> | ||
| </configOptions> | ||
| </configuration> | ||
| </execution> | ||
| </executions> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| </project> |
21 changes: 21 additions & 0 deletions
21
api/src/main/openapi/components/parameters/page-token.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| # This file is part of Dependency-Track. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # Copyright (c) OWASP Foundation. All Rights Reserved. | ||
| name: page_token | ||
| description: Opaque token pointing to a specific position in a collection | ||
| in: query | ||
| schema: | ||
| type: string |
25 changes: 25 additions & 0 deletions
25
api/src/main/openapi/components/parameters/pagination-limit.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| # This file is part of Dependency-Track. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # Copyright (c) OWASP Foundation. All Rights Reserved. | ||
| name: limit | ||
| description: Maximum number of items to retrieve from the collection | ||
| in: query | ||
| schema: | ||
| type: integer | ||
| format: int32 | ||
| minimum: 1 | ||
| maximum: 1000 | ||
| default: 100 |
26 changes: 26 additions & 0 deletions
26
api/src/main/openapi/components/responses/generic-conflict-error.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| # This file is part of Dependency-Track. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||
| # you may not use this file except in compliance with the License. | ||
| # You may obtain a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| # | ||
| # SPDX-License-Identifier: Apache-2.0 | ||
| # Copyright (c) OWASP Foundation. All Rights Reserved. | ||
| description: Forbidden | ||
| content: | ||
| application/problem+json: | ||
| schema: | ||
| $ref: "../schemas/problem-details.yaml" | ||
| example: | ||
| type: about:blank | ||
| status: 409 | ||
| title: Conflict | ||
| detail: The resource already exists. |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.