mirror of
https://github.com/LukeHagar/redocly-cli.git
synced 2025-12-06 12:47:48 +00:00
fix: replace spaces in components prefixes with underscores (#1455)
This commit is contained in:
5
.changeset/yellow-eels-divide.md
Normal file
5
.changeset/yellow-eels-divide.md
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
"@redocly/cli": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Added inflection to the `join` command so that `--prefix-components-with-info-prop` replaces spaces with underscores to create less confusing $refs.
|
||||||
@@ -40,10 +40,10 @@ paths:
|
|||||||
'200':
|
'200':
|
||||||
description: example description
|
description: example description
|
||||||
security:
|
security:
|
||||||
- Foo Example OpenAPI 3 definition foo._scheme1: []
|
- Foo_Example_OpenAPI_3_definition_foo._scheme1: []
|
||||||
Foo Example OpenAPI 3 definition foo._scheme2: []
|
Foo_Example_OpenAPI_3_definition_foo._scheme2: []
|
||||||
Foo Example OpenAPI 3 definition foo._scheme3: []
|
Foo_Example_OpenAPI_3_definition_foo._scheme3: []
|
||||||
Foo Example OpenAPI 3 definition foo._scheme4: []
|
Foo_Example_OpenAPI_3_definition_foo._scheme4: []
|
||||||
tags:
|
tags:
|
||||||
- foo_other
|
- foo_other
|
||||||
/pets/{petId}:
|
/pets/{petId}:
|
||||||
@@ -54,28 +54,28 @@ paths:
|
|||||||
'201':
|
'201':
|
||||||
description: example description
|
description: example description
|
||||||
security:
|
security:
|
||||||
- Bar Example OpenAPI 3 definition._scheme1: []
|
- Bar_Example_OpenAPI_3_definition._scheme1: []
|
||||||
Bar Example OpenAPI 3 definition._scheme2: []
|
Bar_Example_OpenAPI_3_definition._scheme2: []
|
||||||
- Bar Example OpenAPI 3 definition._scheme3: []
|
- Bar_Example_OpenAPI_3_definition._scheme3: []
|
||||||
Bar Example OpenAPI 3 definition._scheme4: []
|
Bar_Example_OpenAPI_3_definition._scheme4: []
|
||||||
tags:
|
tags:
|
||||||
- bar_other
|
- bar_other
|
||||||
components:
|
components:
|
||||||
schemas:
|
schemas:
|
||||||
Foo Example OpenAPI 3 definition foo._some-property:
|
Foo_Example_OpenAPI_3_definition_foo._some-property:
|
||||||
description: foo description
|
description: foo description
|
||||||
type: string
|
type: string
|
||||||
Foo Example OpenAPI 3 definition foo._another-property:
|
Foo_Example_OpenAPI_3_definition_foo._another-property:
|
||||||
description: description
|
description: description
|
||||||
$ref: '#/components/schemas/Foo Example OpenAPI 3 definition foo._some-property'
|
$ref: '#/components/schemas/Foo_Example_OpenAPI_3_definition_foo._some-property'
|
||||||
Bar Example OpenAPI 3 definition._some-property:
|
Bar_Example_OpenAPI_3_definition._some-property:
|
||||||
description: bar description
|
description: bar description
|
||||||
type: string
|
type: string
|
||||||
nullable: true
|
nullable: true
|
||||||
default: null
|
default: null
|
||||||
Bar Example OpenAPI 3 definition._another-property:
|
Bar_Example_OpenAPI_3_definition._another-property:
|
||||||
description: description
|
description: description
|
||||||
$ref: '#/components/schemas/Bar Example OpenAPI 3 definition._some-property'
|
$ref: '#/components/schemas/Bar_Example_OpenAPI_3_definition._some-property'
|
||||||
x-tagGroups:
|
x-tagGroups:
|
||||||
- name: Foo Example OpenAPI 3 definition foo.
|
- name: Foo Example OpenAPI 3 definition foo.
|
||||||
tags:
|
tags:
|
||||||
|
|||||||
@@ -13,15 +13,15 @@ info:
|
|||||||
servers:
|
servers:
|
||||||
- url: https://redocly.com/v1
|
- url: https://redocly.com/v1
|
||||||
tags:
|
tags:
|
||||||
- name: Foo Example OpenAPI 3 definition with foo title._Pet
|
- name: Foo_Example_OpenAPI_3_definition_with_foo_title._Pet
|
||||||
description: Pet Discription
|
description: Pet Discription
|
||||||
x-displayName: Pet
|
x-displayName: Pet
|
||||||
- name: Foo Example OpenAPI 3 definition with foo title._other
|
- name: Foo_Example_OpenAPI_3_definition_with_foo_title._other
|
||||||
x-displayName: other
|
x-displayName: other
|
||||||
- name: Bar Example OpenAPI 3 definition._Pet
|
- name: Bar_Example_OpenAPI_3_definition._Pet
|
||||||
description: Pet Discription
|
description: Pet Discription
|
||||||
x-displayName: Pet
|
x-displayName: Pet
|
||||||
- name: Bar Example OpenAPI 3 definition._other
|
- name: Bar_Example_OpenAPI_3_definition._other
|
||||||
x-displayName: other
|
x-displayName: other
|
||||||
paths:
|
paths:
|
||||||
/pets:
|
/pets:
|
||||||
@@ -40,7 +40,7 @@ paths:
|
|||||||
'200':
|
'200':
|
||||||
description: example description
|
description: example description
|
||||||
tags:
|
tags:
|
||||||
- Foo Example OpenAPI 3 definition with foo title._other
|
- Foo_Example_OpenAPI_3_definition_with_foo_title._other
|
||||||
/pets/{petId}:
|
/pets/{petId}:
|
||||||
post:
|
post:
|
||||||
summary: summary example
|
summary: summary example
|
||||||
@@ -49,17 +49,17 @@ paths:
|
|||||||
'201':
|
'201':
|
||||||
description: example description
|
description: example description
|
||||||
tags:
|
tags:
|
||||||
- Bar Example OpenAPI 3 definition._other
|
- Bar_Example_OpenAPI_3_definition._other
|
||||||
components: {}
|
components: {}
|
||||||
x-tagGroups:
|
x-tagGroups:
|
||||||
- name: Foo Example OpenAPI 3 definition with foo title.
|
- name: Foo Example OpenAPI 3 definition with foo title.
|
||||||
tags:
|
tags:
|
||||||
- Foo Example OpenAPI 3 definition with foo title._Pet
|
- Foo_Example_OpenAPI_3_definition_with_foo_title._Pet
|
||||||
- Foo Example OpenAPI 3 definition with foo title._other
|
- Foo_Example_OpenAPI_3_definition_with_foo_title._other
|
||||||
- name: Bar Example OpenAPI 3 definition.
|
- name: Bar Example OpenAPI 3 definition.
|
||||||
tags:
|
tags:
|
||||||
- Bar Example OpenAPI 3 definition._Pet
|
- Bar_Example_OpenAPI_3_definition._Pet
|
||||||
- Bar Example OpenAPI 3 definition._other
|
- Bar_Example_OpenAPI_3_definition._other
|
||||||
|
|
||||||
openapi.yaml: join processed in <test>ms
|
openapi.yaml: join processed in <test>ms
|
||||||
|
|
||||||
|
|||||||
@@ -259,12 +259,12 @@ describe('handleJoin', () => {
|
|||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
schemas: {
|
schemas: {
|
||||||
'Third API_SchemaWithNull': {
|
Third_API_SchemaWithNull: {
|
||||||
type: 'string',
|
type: 'string',
|
||||||
default: null,
|
default: null,
|
||||||
nullable: true,
|
nullable: true,
|
||||||
},
|
},
|
||||||
'Third API_SchemaWithRef': {
|
Third_API_SchemaWithRef: {
|
||||||
type: 'object',
|
type: 'object',
|
||||||
properties: {
|
properties: {
|
||||||
schemaType: {
|
schemaType: {
|
||||||
@@ -272,21 +272,21 @@ describe('handleJoin', () => {
|
|||||||
enum: ['foo'],
|
enum: ['foo'],
|
||||||
},
|
},
|
||||||
foo: {
|
foo: {
|
||||||
$ref: '#/components/schemas/Third API_SchemaWithNull',
|
$ref: '#/components/schemas/Third_API_SchemaWithNull',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
'Third API_SchemaWithDiscriminator': {
|
Third_API_SchemaWithDiscriminator: {
|
||||||
discriminator: {
|
discriminator: {
|
||||||
propertyName: 'schemaType',
|
propertyName: 'schemaType',
|
||||||
mapping: {
|
mapping: {
|
||||||
foo: '#/components/schemas/Third API_SchemaWithRef',
|
foo: '#/components/schemas/Third_API_SchemaWithRef',
|
||||||
bar: '#/components/schemas/Third API_SchemaWithNull',
|
bar: '#/components/schemas/Third_API_SchemaWithNull',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
oneOf: [
|
oneOf: [
|
||||||
{
|
{
|
||||||
$ref: '#/components/schemas/Third API_SchemaWithRef',
|
$ref: '#/components/schemas/Third_API_SchemaWithRef',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
type: 'object',
|
type: 'object',
|
||||||
|
|||||||
@@ -784,7 +784,7 @@ function getInfoPrefix(info: any, prefixArg: string | undefined, type: string) {
|
|||||||
`prefix-${type}-with-info-prop`
|
`prefix-${type}-with-info-prop`
|
||||||
)} argument value length should not exceed 50 characters. \n\n`
|
)} argument value length should not exceed 50 characters. \n\n`
|
||||||
);
|
);
|
||||||
return info[prefixArg];
|
return info[prefixArg].replaceAll(/\s/g, '_');
|
||||||
}
|
}
|
||||||
|
|
||||||
async function validateApi(
|
async function validateApi(
|
||||||
|
|||||||
Reference in New Issue
Block a user