Skip to content

Conversation

@antoineauger
Copy link

@antoineauger antoineauger commented Feb 17, 2022

Description

This PR aims at allowing users to customize the URLs used by the Swagger Editor codegen features (e.g., Generate Server and Generate Client).

The URLs that can now be customized are:

For Docker users, this is made possible by the introduction of 3 new environment variables: URL_SWAGGER2_GENERATOR URL_OAS3_GENERATOR and URL_SWAGGER2_CONVERTER, respectively.

Motivation and Context

This PR can be interesting for:

Fixes #1488
Fixes #2688
Fixes #2127

/cc @fgreinacher @dlouzan

How Has This Been Tested?

For Docker env variables, created several docker containers with various values for env variables URL_SWAGGER2_GENERATOR, URL_OAS3_GENERATOR and URL_SWAGGER2_CONVERTER. Then logging on startup:

console.log(mergedOptions)

Also tested that setting these variables to null was disabling the Swagger Editor codegen features:

docker run -e URL_SWAGGER2_GENERATOR="null" -e URL_OAS3_GENERATOR="null" -e URL_SWAGGER2_CONVERTER="null" -d -p 9999:8080 swagger-editor

Checklist

My PR contains...

  • No code changes (src/ is unmodified: changes to documentation, CI, metadata, etc.)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fixes (non-breaking change which fixes an issue)
  • Improvements (misc. changes to existing features)
  • Features (non-breaking change which adds functionality)

My changes...

  • are breaking changes to a public API (config options, System API, major UI change, etc).
  • are breaking changes to a private API (Redux, component props, utility functions, etc.).
  • are breaking changes to a developer API (npm script behavior changes, new dev system dependencies, etc).
  • are not breaking changes.

Documentation

  • My changes do not require a change to the project documentation.
  • My changes require a change to the project documentation.
  • If yes to above: I have updated the documentation accordingly.

Automated tests

  • My changes can not or do not need to be tested.
  • My changes can and should be tested by unit and/or integration tests.
  • If yes to above: I have added tests to cover my changes.
  • If yes to above: I have taken care to cover edge cases in my tests.
  • All new and existing tests passed.

🛠️ with ❤️ by Siemens

@char0n char0n self-assigned this Feb 21, 2022
@char0n
Copy link
Contributor

char0n commented Feb 21, 2022

@antoineauger thanks a lot for contributing. We'll look into the PR ASAP.

Copy link
Contributor

@char0n char0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! Please have a look at my code review comments.

@antoineauger antoineauger force-pushed the ft/swagger-editor-codegen-urls branch from 3fafd77 to 5774d33 Compare March 8, 2022 16:50
@antoineauger antoineauger force-pushed the ft/swagger-editor-codegen-urls branch from 5ad761a to 45fe767 Compare March 8, 2022 17:01
@antoineauger
Copy link
Author

Thanks for contributing! Please have a look at my code review comments.

Thanks for the review @char0n, this PR is way much simpler now.

I think I addressed all your comments, could you have another look at it? 🙏🏻

@antoineauger antoineauger requested a review from char0n March 8, 2022 17:06
Copy link
Contributor

@char0n char0n left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work! Changes look good! I'll have to some local testing with changes from this PR before the merge.

@char0n
Copy link
Contributor

char0n commented Mar 10, 2022

Testing went fine. All works as expected. THanks again!

@char0n char0n merged commit 2627a67 into swagger-api:master Mar 10, 2022
@antoineauger antoineauger deleted the ft/swagger-editor-codegen-urls branch March 10, 2022 13:35
antoineauger referenced this pull request in SmartDever02/swagger-editor Jan 9, 2026
- Add support for REACT_APP_* environment variables for all codegen URLs
- Update selectors to use env vars with fallback to default URLs
- Document new environment variables in README.md
- Maintains backward compatibility with default URLs

Fixes swagger-api#5680
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants