Giter Site home page Giter Site logo

Comments (3)

thim81 avatar thim81 commented on May 19, 2024 1

@wedi I ll make a PR as soon as I have some time.

I ll make it a separate cli option, so that you can have the choice if you want to split the config or have 1 central file.

from openapi-format.

thim81 avatar thim81 commented on May 19, 2024

@wedi Thanks (again) for the valuable feedback.

Which configurations would you like to see merged?

In the CI flow, that we are using, we use it to format and filter 1 OpenAPI and store multiple results in seperate OpenAPI files.

Example:

  • public documentation for production
  • internal preview documentation (which contains upcoming endpoints)
  • an OpenAPI for Newman with a subset for tests.

from openapi-format.

wedi avatar wedi commented on May 19, 2024

That's a pretty neat workflow and I believe my suggestion wouldn't break it. You could keep the existing parameters and document that they overwrite the combined config file. (Although that might make it more complicated than it needs to be.)

Which configurations would you like to see merged?

All of them. 🤓 Similar to this:

{
  "file": "src/openapi.yaml",   // file and string or files and [] if you decide to allow multiple (globs)
  "filter": {
    "methods": [],
    "tags": [],
    "operationIds": [],
    "operations": [],
    "flags": [],
    "flagValues": [],
    "unusedComponents": [],
    "stripFlags": []
  },
  "lineWidth": -1,    // maybe 0 should do the same?
  "sort": {   // set to false for `no-sort`
    "root": ["openapi", "info", "servers", "paths", "components", "tags", "x-tagGroups", "externalDocs"],
    "get": ["operationId", "summary", "description", "parameters", "requestBody", "responses"],
    "post": ["operationId", "summary", "description", "parameters", "requestBody", "responses"],
    "put": ["operationId", "summary", "description", "parameters", "requestBody", "responses"],
    "patch": ["operationId", "summary", "description", "parameters", "requestBody", "responses"],
    "delete": ["operationId", "summary", "description", "parameters", "requestBody", "responses"],
    "parameters": ["name", "in", "description", "required", "schema"],
    "requestBody": ["description", "headers", "content", "links"],
    "responses": ["description", "headers", "content", "links"],
    "content": [],
    "components": ["parameters", "schemas"],
    "schema": ["description", "type", "items", "properties", "format", "example", "default"],
    "schemas": ["description", "type", "items", "properties", "format", "example", "default"],
    "properties": ["description", "type", "items", "format", "example", "default", "enum"]
  },
  "sort-components": [],
  "verbose": false,
}

I have two reasons for this suggestion.

  1. Less clutter in already cluttered root directories
  2. It would allow to replace
    openapi-format --sortFile .openapi-format-sort.json --sortComponentsFile .openapi-format-sort-components.json --filterFile .openapi-format-filter.json src/openapi.yaml -o src/openapi.yaml
    with
    openapi-format src/openapi.yaml -o src/openapi.yaml
    or even openapi-format . per my other suggestion.

Looking at eslint and prettier it seems -c|--config would be a sensible choice for a parameter to use a config file for a certain job and it would allow you to keep --configFile for backwards compatibility if desired (but it would break -c).

I digged into eslint and they use a highly customized config loader whereas prettier uses a library called cosmicconfig. They have lodash in their dependency list, too, so they might use that to merge with default settings.

from openapi-format.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.