question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Provide a way to enforce file names

See original GitHub issue

Currently, you can only create visitors for a node type. We would like to be able specify a visitor for a file.

An example would be if I would like to enforce that all the schemas in a file need to be in alphabetical order.

Currently, to add rules for a specific file I have to specify a random OpenAPISchema type definition in a rule, check that the context.filePath is in the file that I expect, and then apply my validation rules.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
JamesMessingercommented, Jan 13, 2020

This would be a killer feature for us. We want to use openapi-cli as a linter that enforces a consistent folder/file structure in all of our APIs, so any developer in the company can easily work on any API in the company without having to learn a new structure each time. Here’s the structure that we’re enforcing:

|-- openapi.yaml      (the main/entry file)
|-- info.yaml         (the info section)
|-- tags.yaml         (the tags section)
|-- paths/
| |-- foo/
|   |-- bar/
|     |-- path.yaml   (the definition of the /foo/bar path)
|     |-- get.yaml    (the definition of the GET /foo/bar operation)
|     |-- post.yaml   (the definition of the POST /foo/bar operation)
|
|-- schemas/
  |-- enums.yaml      (all enumerations are defined here)
  |-- fizz.yaml       (the JSON schema for fizz objects)
  |-- buzz.yaml       (the JSON schema for buzz objects)

So we need to be able to create file-level rules such as:

  • The main entry file of the API definition must be named openapi.yaml
  • info.yaml must exist and must contain the API’s info section
  • tags.yaml must exist and must contain the list of tags
  • Every path in the API must have a corresponding paths/xxx/yyy/path.yaml file
  • Every operation in the API must have a corresponding paths/xxx/yyy/VERB.yaml file
  • Every object schema must be defined in a corresponding schemas/xxx.yaml file
  • All enumerations must be in enums.yaml
  • The enumerations in enums.yaml must be in alphabetical order
0reactions
adamaltmancommented, Jul 25, 2022

I’m going to close this since it can be used for $ref filename checks. I’m not sure what other filename would want to be checked besides the root file?

Read more comments on GitHub >

github_iconTop Results From Across the Web

How can I enforce filename and folder name convention in ...
I am looking for a rule which can enforce filename to be camelCase and folder name to be snake_case . How can I...
Read more >
Enforce File Names Conventions · Issue #2412 - GitHub
One thing I've noticed in my code-base is that it's hard to get people to stay consistent on file naming conventions.
Read more >
Use GPO to enforce file naming convention for users
The only thing you can do to facilitate this with GPO's is enforce audit policies on key shares and then use a log...
Read more >
File Naming Conventions | Data Management
A file naming convention is a framework for naming your files in a way that describes what they contain and how they relate...
Read more >
File Naming Conventions - HURIDOCS
A file naming convention is a systematic method for naming files that will ... Use relevant components in your file names to provide...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found