Skip to content

Commit 91aac4e

Browse files
FdawgsTony133
andauthored
docs: fix broken links (#930)
Co-authored-by: Antonio Tripodi <Tony133@users.noreply.github.com>
1 parent a10dfde commit 91aac4e

3 files changed

Lines changed: 17 additions & 15 deletions

File tree

README.md

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
[![CI](https://github.com/fastify/fastify-swagger/actions/workflows/ci.yml/badge.svg?branch=main)](https://github.com/fastify/fastify-swagger/actions/workflows/ci.yml)
55
[![neostandard javascript style](https://img.shields.io/badge/code_style-neostandard-brightgreen?style=flat)](https://github.com/neostandard/neostandard)
66

7-
A Fastify plugin for serving [Swagger (OpenAPI v2)](https://swagger.io/specification/v2/) or [OpenAPI v3](https://swagger.io/specification) schemas, which are automatically generated from your route schemas, or an existing Swagger/OpenAPI schema.
7+
A Fastify plugin for serving [Swagger (OpenAPI v2)](https://swagger.io/specification/v2/) or [OpenAPI v3](https://swagger.io/specification/) schemas, which are automatically generated from your route schemas, or an existing Swagger/OpenAPI schema.
88

99
If you are looking for a plugin to generate routes from an existing OpenAPI schema, check out [fastify-openapi-glue](https://github.com/seriousme/fastify-openapi-glue).
1010

@@ -337,7 +337,7 @@ await fastify.register(require('@fastify/swagger'), {
337337
In `dynamic` mode, this plugin resolves all `$ref`s in the application's schemas, creating a new in-line schema that references itself.
338338
This ensures the generated documentation is valid, preventing Swagger UI from failing to fetch schemas from the server or network.
339339
340-
By default, this option resolves all `$ref`s, renaming them to `def-${counter}`, while view models keep the original `$id` naming using the [`title` parameter](https://swagger.io/docs/specification/2-0/basic-structure/#metadata).
340+
By default, this option resolves all `$ref`s, renaming them to `def-${counter}`, while view models keep the original `$id` naming using the [`title` parameter](https://swagger.io/docs/specification/v2_0/basic-structure/#metadata).
341341
342342
This logic can be customized by passing a `refResolver` option to the plugin:
343343
@@ -574,7 +574,7 @@ Specify the `type` property when decorating response headers to prevent schema m
574574
575575
<a name="route.response.empty_body"></a>
576576
##### Different content types responses
577-
> ℹ️ Note: Supported [only by OpenAPI v3](https://swagger.io/docs/specification/describing-responses/), not Swagger (OpenAPI v2).
577+
> ℹ️ Note: Supported [only by OpenAPI v3](https://swagger.io/docs/specification/v3_0/describing-responses/), not Swagger (OpenAPI v2).
578578
579579
Different content types are supported by `@fastify/swagger` and `@fastify`.
580580
Use `content` for the response to prevent Fastify from failing to compile the schema:
@@ -627,14 +627,14 @@ Specify `type: 'null'` for the response to prevent Fastify from failing to compi
627627
628628
> ℹ️ Note: OpenAPI's terminology differs from Fastify's. OpenAPI uses "parameter" to refer to parts of a request that in [Fastify's validation documentation](https://fastify.dev/docs/latest/Reference/Validation-and-Serialization/) are called "querystring", "params", and "headers".
629629
630-
OpenAPI extends the [JSON schema specification](https://json-schema.org/specification.html) with options like `collectionFormat` for encoding array parameters.
630+
OpenAPI extends the [JSON schema specification](https://json-schema.org/specification) with options like `collectionFormat` for encoding array parameters.
631631
632632
These encoding options only affect how Swagger UI presents documentation and generates `curl` commands.
633633
Depending on the schema options, you may need to change Fastify's default query string parser to produce a JavaScript object conforming to the schema.
634634
The default parser conforms to `collectionFormat: "multi"`.
635635
For `collectionFormat: "csv"`, replace the default parser with one that parses CSV values into arrays. This applies to other request parts that OpenAPI calls "parameters" and are not encoded as JSON.
636636
637-
Different serialization `style` and `explode` can also be applied as specified [here](https://swagger.io/docs/specification/serialization/#query).
637+
Different serialization `style` and `explode` can also be applied as specified [here](https://swagger.io/docs/specification/v3_0/serialization/#query).
638638
639639
`@fastify/swagger` supports these options as shown in this example:
640640
@@ -689,7 +689,7 @@ There is a complete runnable example [here](examples/collection-format.js).
689689
<a name="route.complex-serialization"></a>
690690
#### Complex serialization in query and cookie, eg. JSON
691691
692-
> ℹ️ Note: Supported [only by OpenAPI v3](https://swagger.io/docs/specification/describing-parameters/#schema-vs-content), not Swagger (OpenAPI v2).
692+
> ℹ️ Note: Supported [only by OpenAPI v3](https://swagger.io/docs/specification/v3_0/describing-parameters/#schema-vs-content), not Swagger (OpenAPI v2).
693693
694694
```
695695
http://localhost/?filter={"foo":"baz","bar":"qux"}
@@ -904,7 +904,7 @@ Generates this in the OpenAPI v3 schema's `paths`:
904904
<a name="route.links"></a>
905905
#### Links
906906
907-
> ℹ️ Note: Supported [only by OpenAPI v3](https://swagger.io/docs/specification/links), not Swagger (OpenAPI v2).
907+
> ℹ️ Note: Supported [only by OpenAPI v3](https://swagger.io/docs/specification/v3_0/links/), not Swagger (OpenAPI v2).
908908
909909
Add OpenAPI v3 Links by adding a `links` property to the top-level options of a route. See:
910910
@@ -1006,7 +1006,7 @@ This plugin can be integrated with `@fastify/helmet` with minimal effort:
10061006
<a name="schema.examplesField"></a>
10071007
### Add examples to the schema
10081008
1009-
[OpenAPI](https://swagger.io/specification/#example-object) and [JSON Schema](https://json-schema.org/draft/2020-12/json-schema-validation.html#rfc.section.9.5) have different examples field formats.
1009+
[OpenAPI](https://swagger.io/specification/#example-object) and [JSON Schema](https://json-schema.org/draft/2020-12/json-schema-validation) have different examples field formats.
10101010
10111011
Array with examples from JSON Schema converted to OpenAPI `example` or `examples` field automatically with generated names (example1, example2...):
10121012
@@ -1148,7 +1148,9 @@ The `/docs/json` endpoint in dynamic mode produces a single `swagger.json` file,
11481148
11491149
This project is kindly sponsored by:
11501150
- [nearForm](https://nearform.com)
1151-
- [LetzDoIt](https://www.letzdoitapp.com/)
1151+
1152+
Past sponsors:
1153+
- LetzDoIt
11521154
11531155
<a name="license"></a>
11541156
## License

lib/spec/openapi/utils.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ function convertExamplesArrayToObject (examples) {
132132
}
133133

134134
// For supported keys read:
135-
// https://swagger.io/docs/specification/describing-parameters/
135+
// https://swagger.io/docs/specification/v3_0/describing-parameters/
136136
function plainJsonObjectToOpenapi3 (opts, container, jsonSchema, externalSchemas, securityIgnores = []) {
137137
const localJsonSchema = resolveLocalRef(jsonSchema, externalSchemas)
138138
const obj = convertJsonSchemaToOpenapi3(opts, localJsonSchema)
@@ -151,7 +151,7 @@ function plainJsonObjectToOpenapi3 (opts, container, jsonSchema, externalSchemas
151151
const media = schemaToMedia(jsonSchemaElement)
152152

153153
// complex serialization in query or cookie, eg. JSON
154-
// https://swagger.io/docs/specification/describing-parameters/#schema-vs-content
154+
// https://swagger.io/docs/specification/v3_0/describing-parameters/#schema-vs-content
155155
if (jsonSchemaElement[xConsume]) {
156156
media.schema.required = jsonSchemaElement[rawRequired]
157157

@@ -309,7 +309,7 @@ function findReferenceDescription (rawSchema, ref) {
309309
return resolved?.description
310310
}
311311

312-
// https://swagger.io/docs/specification/describing-responses/
312+
// https://swagger.io/docs/specification/v3_0/describing-responses/
313313
function resolveResponse (opts, fastifyResponseJson, produces, ref) {
314314
// if the user does not provided an out schema
315315
if (!fastifyResponseJson) {
@@ -541,7 +541,7 @@ function convertJsonSchemaToOpenapi3 (opts, jsonSchema) {
541541

542542
if (opts.convertConstToEnum && key === 'const') {
543543
// OAS 3.1 supports `const` but it is not supported by `swagger-ui`
544-
// https://swagger.io/docs/specification/data-models/keywords/
544+
// https://swagger.io/docs/specification/v3_0/data-models/keywords/
545545
// TODO: check if enum property already exists
546546
// TODO: this breaks references to the const property
547547
openapiSchema.enum = [openapiSchema.const]

lib/spec/swagger/utils.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function normalizeUrl (url, basePath, stripBasePath) {
105105
}
106106

107107
// For supported keys read:
108-
// https://swagger.io/docs/specification/2-0/describing-parameters/
108+
// https://swagger.io/docs/specification/v2_0/describing-parameters/
109109
function plainJsonObjectToSwagger2 (container, jsonSchema, externalSchemas, securityIgnores = []) {
110110
const obj = resolveLocalRef(jsonSchema, externalSchemas)
111111
let toSwaggerProp
@@ -212,7 +212,7 @@ function findReferenceDescription (rawSchema, ref) {
212212
return resolved?.description
213213
}
214214

215-
// https://swagger.io/docs/specification/2-0/describing-responses/
215+
// https://swagger.io/docs/specification/v2_0/describing-responses/
216216
function resolveResponse (fastifyResponseJson, ref) {
217217
// if the user does not provided an out schema
218218
if (!fastifyResponseJson) {

0 commit comments

Comments
 (0)