@redocly/openapi-core 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @redocly/openapi-core
2
2
 
3
+ ## 1.1.0
4
+
5
+ ### Minor Changes
6
+
7
+ - Added `ignoreCase` option for `tags-alphabetical` rule.
8
+
9
+ ### Patch Changes
10
+
11
+ - Fixed an issue where the `--remove-unused-components` option removed used components that were referenced as child objects.
12
+ - Updated Redocly config validation.
13
+ - Fixed the location pointer when reporting on the `no-path-trailing-slash` rule.
14
+
3
15
  ## 1.0.2
4
16
 
5
17
  ## 1.0.1
package/lib/bundle.d.ts CHANGED
@@ -39,4 +39,4 @@ export declare function bundleDocument(opts: {
39
39
  removeUnusedComponents?: boolean;
40
40
  keepUrlRefs?: boolean;
41
41
  }): Promise<BundleResult>;
42
- export declare function mapTypeToComponent(typeName: string, version: OasMajorVersion): "headers" | "definitions" | "parameters" | "examples" | "schemas" | "responses" | "requestBodies" | "securitySchemes" | "links" | "callbacks" | null;
42
+ export declare function mapTypeToComponent(typeName: string, version: OasMajorVersion): "parameters" | "examples" | "headers" | "schemas" | "responses" | "requestBodies" | "securitySchemes" | "links" | "callbacks" | "definitions" | null;
@@ -18,5 +18,5 @@ declare type YAMLScalar = yamlAst.YAMLScalar & {
18
18
  declare type YAMLNode = YAMLMapping | YAMLMap | YAMLAnchorReference | YAMLSequence | YAMLScalar;
19
19
  export declare function getCodeframe(location: LineColLocationObject, color: boolean): string;
20
20
  export declare function getLineColLocation(location: LocationObject): LineColLocationObject;
21
- export declare function getAstNodeByPointer(root: YAMLNode, pointer: string, reportOnKey: boolean): yamlAst.YAMLScalar | YAMLMapping | YAMLMap | YAMLAnchorReference | YAMLSequence | undefined;
21
+ export declare function getAstNodeByPointer(root: YAMLNode, pointer: string, reportOnKey: boolean): YAMLMapping | YAMLMap | YAMLAnchorReference | YAMLSequence | yamlAst.YAMLScalar | undefined;
22
22
  export {};
@@ -3,11 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.NoPathTrailingSlash = void 0;
4
4
  const NoPathTrailingSlash = () => {
5
5
  return {
6
- PathItem(_path, { report, key, location }) {
6
+ PathItem(_path, { report, key, rawLocation }) {
7
7
  if (key.endsWith('/') && key !== '/') {
8
8
  report({
9
9
  message: `\`${key}\` should not have a trailing slash.`,
10
- location: location.key(),
10
+ location: rawLocation.key(),
11
11
  });
12
12
  }
13
13
  },
@@ -1,13 +1,13 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.TagsAlphabetical = void 0;
4
- const TagsAlphabetical = () => {
4
+ const TagsAlphabetical = ({ ignoreCase = false }) => {
5
5
  return {
6
6
  Root(root, { report, location }) {
7
7
  if (!root.tags)
8
8
  return;
9
9
  for (let i = 0; i < root.tags.length - 1; i++) {
10
- if (root.tags[i].name > root.tags[i + 1].name) {
10
+ if (getTagName(root.tags[i], ignoreCase) > getTagName(root.tags[i + 1], ignoreCase)) {
11
11
  report({
12
12
  message: 'The `tags` array should be in alphabetical order.',
13
13
  location: location.child(['tags', i]),
@@ -18,3 +18,6 @@ const TagsAlphabetical = () => {
18
18
  };
19
19
  };
20
20
  exports.TagsAlphabetical = TagsAlphabetical;
21
+ function getTagName(tag, ignoreCase) {
22
+ return ignoreCase ? tag.name.toLowerCase() : tag.name;
23
+ }
@@ -19,7 +19,10 @@ const RemoveUnusedComponents = () => {
19
19
  const resolvedRef = resolve(ref);
20
20
  if (!resolvedRef.location)
21
21
  return;
22
- components.set(resolvedRef.location.absolutePointer, {
22
+ const [fileLocation, localPointer] = resolvedRef.location.absolutePointer.split('#', 2);
23
+ const componentLevelLocalPointer = localPointer.split('/').slice(0, 3).join('/');
24
+ const pointer = `${fileLocation}#${componentLevelLocalPointer}`;
25
+ components.set(pointer, {
23
26
  used: true,
24
27
  name: key.toString(),
25
28
  });
@@ -19,7 +19,10 @@ const RemoveUnusedComponents = () => {
19
19
  const resolvedRef = resolve(ref);
20
20
  if (!resolvedRef.location)
21
21
  return;
22
- components.set(resolvedRef.location.absolutePointer, {
22
+ const [fileLocation, localPointer] = resolvedRef.location.absolutePointer.split('#', 2);
23
+ const componentLevelLocalPointer = localPointer.split('/').slice(0, 4).join('/');
24
+ const pointer = `${fileLocation}#${componentLevelLocalPointer}`;
25
+ components.set(pointer, {
23
26
  used: true,
24
27
  name: key.toString(),
25
28
  });
@@ -1,7 +1,7 @@
1
1
  import { UserContext } from '../walk';
2
2
  import { Location } from '../ref-utils';
3
3
  import { Oas3Schema, Referenced } from '../typings/openapi';
4
- export declare function oasTypeOf(value: unknown): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "null" | "integer" | "array";
4
+ export declare function oasTypeOf(value: unknown): "string" | "number" | "bigint" | "boolean" | "symbol" | "undefined" | "object" | "function" | "integer" | "array" | "null";
5
5
  /**
6
6
  * Checks if value matches specified JSON schema type
7
7
  *